imagebridge

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package imagebridge transports bounded normalized images into one live remote Coding TUI without creating files or durable Runtime events.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrProtocol means a bridge frame or token violated the fixed wire contract.
	ErrProtocol = errors.New("coding image bridge: invalid protocol")
	// ErrDeadline means a bridge frame expired or requested an excessive lifetime.
	ErrDeadline = errors.New("coding image bridge: invalid deadline")
	// ErrPeer means a Unix socket peer did not match the owning user.
	ErrPeer = errors.New("coding image bridge: invalid peer")
	// ErrUnavailable means the process-owned bridge endpoint is unavailable.
	ErrUnavailable = errors.New("coding image bridge: unavailable")
	// ErrBusy means the live TUI inbox has reached its fixed capacity.
	ErrBusy = errors.New("coding image bridge: busy")
	// ErrClosed means the live bridge has stopped.
	ErrClosed = errors.New("coding image bridge: closed")
)

Functions

func Encode

func Encode(writer io.Writer, frame Frame) error

Encode writes one complete strict frame. The caller owns framing EOF, such as closing the write half of a Unix connection after this function returns.

func NewNonce

func NewNonce() (string, error)

NewNonce returns a fresh 256-bit base64url bridge nonce.

func Send

func Send(ctx context.Context, nonce string, frame Frame) error

Send validates the endpoint and transfers one image to the matching live bridge, waiting for its bounded acknowledgement.

func ValidateNonce

func ValidateNonce(value string) error

ValidateNonce accepts only the canonical 256-bit base64url representation.

Types

type Frame

type Frame struct {
	Image    attachment.Image
	Notice   Notice
	Deadline time.Time
}

Frame is one validated image or notice with its original absolute deadline.

func Decode

func Decode(ctx context.Context, reader io.Reader, now time.Time) (Frame, error)

Decode reads exactly one strict frame and requires EOF after its body.

type Notice

type Notice uint8

Notice is an allowlisted bridge acknowledgement.

const (
	// NoticeUnknown is the zero value and never valid on the wire.
	NoticeUnknown Notice = iota
	// NoticeAccepted confirms that the live TUI accepted an image.
	NoticeAccepted
	// NoticeBusy reports that the fixed live TUI inbox is full.
	NoticeBusy
	// NoticeRejected reports invalid image input without echoing details.
	NoticeRejected
)

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server owns one nonce-scoped private Unix socket and bounded image inbox.

func Listen

func Listen(ctx context.Context, nonce string) (*Server, error)

Listen creates one process-owned endpoint under /tmp/pips-bridge-<uid>.

func (*Server) Close

func (s *Server) Close() error

Close stops admission, waits for the receiver, and removes only the socket inode created by this Server.

func (*Server) Receive

func (s *Server) Receive(ctx context.Context) (attachment.Image, error)

Receive waits for one already-validated immutable image.

Jump to

Keyboard shortcuts

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