streamwire

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package streamwire defines experimental USB-only EPS1 records. CRC detects corruption, not forgery. Never expose this framing as authenticated Wi-Fi.

Index

Constants

View Source
const HeaderSize = 32
View Source
const MaxPayload = 100
View Source
const MaxRecord = HeaderSize + MaxPayload

Variables

View Source
var ErrRecord = errors.New("stream wire: invalid record")

Functions

func Encode

func Encode(dst []byte, r Record) (int, error)

Encode borrows Payload. Decode aliases its input; consume before reusing it.

func Send

func Send(stream io.ReadWriter, epoch uint64, frame display.Frame) error

Send borrows an immutable server-side frame. The stream must impose I/O deadlines. A failure is not automatically retried: completion may be unknown. Epoch is a fresh nonzero host random value for this physical USB session.

func Size

func Size(header []byte) (int, error)

Types

type Kind

type Kind uint8
const (
	Hello Kind = iota + 1
	Begin
	Data
	Commit
	Query
	Abort
	Reply
)
type Link struct {
	// contains filtered or unexported fields
}

Link is owned by one USB loop and retained across disconnects so reconnect cannot bypass refresh cadence. Call Tick even without incoming bytes.

func NewLink(config streamrx.Config, sink streamrx.Sink, interval time.Duration) (*Link, error)

func (*Link) Disconnect

func (l *Link) Disconnect() error

func (*Link) Push

func (l *Link) Push(src []byte, now time.Duration, write func([]byte) error) error

Push accepts arbitrary fragmentation but sends one reply per complete record. A malformed frame closes the session; caller must drop DTR/reopen to resync.

func (*Link) Tick

func (l *Link) Tick(now time.Duration) error

type Record

type Record struct {
	Kind      Kind
	Pass      uint8
	Epoch, ID uint64
	Offset    uint32
	Payload   []byte
}

func Decode

func Decode(src []byte) (Record, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL