Documentation
¶
Overview ¶
Package streamrx validates bounded full-image passes before allowing refresh. It is an experimental single-owner state machine, not a wire codec or auth layer. Callers must authenticate chunks, serialize access, poll Tick even when input stops, and Close on disconnect. No controller commands live here.
Index ¶
- Variables
- type ChunkedSink
- type Config
- type Intent
- type Receiver
- func (r *Receiver) Begin(intent Intent, now time.Duration) error
- func (r *Receiver) Close() error
- func (r *Receiver) Commit(intent Intent, now time.Duration) error
- func (r *Receiver) Invalidate(cause error) error
- func (r *Receiver) Status() Status
- func (r *Receiver) Tick(now time.Duration) error
- func (r *Receiver) Write(intent Intent, pass uint8, offset uint32, pixels []byte, now time.Duration) error
- type Sink
- type State
- type Status
Constants ¶
This section is empty.
Variables ¶
var ( ErrConfig = errors.New("stream: configuration") ErrState = errors.New("stream: state or intent conflict") ErrChunk = errors.New("stream: chunk bounds, order or padding") ErrDigest = errors.New("stream: pass digest mismatch") ErrTimeout = errors.New("stream: deadline or clock regression") )
Functions ¶
This section is empty.
Types ¶
type ChunkedSink ¶
type ChunkedSink struct {
// contains filtered or unexported fields
}
func NewChunkedSink ¶
func NewChunkedSink(sink Sink, limit int) (*ChunkedSink, error)
NewChunkedSink adapts authenticated logical chunks to a controller's smaller write quantum. It borrows slices, allocates no staging buffer and preserves pass/absolute offset. Receiver still owns validation, abort and commit order.
func (*ChunkedSink) Abort ¶
func (s *ChunkedSink) Abort() error
func (*ChunkedSink) Begin ¶
func (s *ChunkedSink) Begin() error
func (*ChunkedSink) Commit ¶
func (s *ChunkedSink) Commit() error
type Config ¶
type Config struct {
Epoch uint64
Width, Height uint16
Passes uint8
MaxChunk int
Idle, Total time.Duration
}
Config is negotiated locally; dimensions and passes cannot change mid-session. Epoch must be fresh on reboot/reconnect; its generation belongs to transport. Idle/Total bound input waiting, not synchronous sink execution or panel BUSY.
type Intent ¶
Intent identifies one immutable target. ID increases strictly within Epoch. Digest covers canonical 1bpp pixels, 1=black, MSB-first, zero row padding. Every pass carries identical logical pixels; the sink owns plane polarity.
type Receiver ¶
type Receiver struct {
// contains filtered or unexported fields
}
func (*Receiver) Begin ¶
Begin never repeats a confirmed refresh. A failed intent needs a new ID and full upload; a new receiver/epoch cannot attest a previous epoch's outcome.
func (*Receiver) Invalidate ¶
Invalidate discards active staging after a transport-level validation failure.
func (*Receiver) Tick ¶
Tick must run from the owner loop during idle input too. No background timer or goroutine is created. Deadlines expire at equality and never extend Total.
func (*Receiver) Write ¶
func (r *Receiver) Write(intent Intent, pass uint8, offset uint32, pixels []byte, now time.Duration) error
Write accepts exactly the next nonempty chunk. Duplicates are rejected rather than replayed into an unknown controller write pointer. Authentication must precede this call; SHA-256 consistency is not sender authentication.
type Sink ¶
type Sink interface {
Begin() error
Write(pass uint8, offset uint32, pixels []byte) error
Commit() error
Abort() error
}
Sink borrows Write bytes only until return. Begin prepares staging without refresh; Commit owns safe refresh cadence/BUSY/sleep. Abort must release power without refreshing, including after a partially failed Begin or Commit. Sink calls must be bounded; reentry into Receiver is forbidden.