streamrx

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: 4 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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

func (*ChunkedSink) Write

func (s *ChunkedSink) Write(pass uint8, offset uint32, pixels []byte) 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

type Intent struct {
	Epoch, ID uint64
	Digest    [sha256.Size]byte
}

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 New

func New(config Config, sink Sink) (*Receiver, error)

func (*Receiver) Begin

func (r *Receiver) Begin(intent Intent, now time.Duration) error

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) Close

func (r *Receiver) Close() error

func (*Receiver) Commit

func (r *Receiver) Commit(intent Intent, now time.Duration) error

func (*Receiver) Invalidate

func (r *Receiver) Invalidate(cause error) error

Invalidate discards active staging after a transport-level validation failure.

func (*Receiver) Status

func (r *Receiver) Status() Status

func (*Receiver) Tick

func (r *Receiver) Tick(now time.Duration) error

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.

type State

type State uint8
const (
	Idle State = iota
	Receiving
	Ready
	Complete
	Failed
	Closed
)

type Status

type Status struct {
	Intent  Intent
	State   State
	Pass    uint8
	Offset  uint32
	Failure error
}

Jump to

Keyboard shortcuts

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