Documentation
¶
Overview ¶
Package channel defines the protocol-neutral lifecycle of an established bidirectional byte stream.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNilStream is returned when a Stream is created without an underlying // bidirectional byte stream. ErrNilStream = errors.New("channel stream must not be nil") // ErrNotOpen is returned when I/O is attempted after a Channel has stopped // accepting reads or writes. ErrNotOpen = errors.New("channel is not open") // ErrResizeUnsupported is returned when a Channel has no terminal-size // capability. ErrResizeUnsupported = errors.New("channel does not support terminal resizing") )
Functions ¶
This section is empty.
Types ¶
type Channel ¶
type Channel interface {
Read(p []byte) (int, error)
Write(p []byte) (int, error)
Close() error
State() State
}
Channel is an established, protocol-neutral bidirectional byte stream.
Implementations own the live stream resource until Close returns. Read and Write follow the standard library contracts and must not retain caller-owned buffers. Close must be safe to call repeatedly. State is a point-in-time lifecycle snapshot and must not be used as a concurrency guard.
type Resizer ¶
Resizer is an optional Channel capability for terminal-like streams.
Generic Session behavior does not require this capability. Terminal adapters may request it without making file, debug, or other byte streams implement a meaningless terminal operation.
type State ¶
type State uint8
State describes the lifecycle stage of an established Channel.
const ( // StateOpen indicates that the Channel accepts reads and writes. StateOpen State = iota // StateClosing indicates that Close is releasing the underlying stream. StateClosing // StateClosed indicates that Close has finished. StateClosed // StateFailed indicates that an underlying read or write failed. StateFailed )
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Stream gives an io.ReadWriteCloser Channel lifecycle and idempotent cleanup.
Stream is useful when a Transport opens a standard Go byte stream that does not need additional Channel capabilities.
func NewStream ¶
func NewStream(stream io.ReadWriteCloser) (*Stream, error)
NewStream takes ownership of an already-open stream and returns an open Channel. The stream remains owned by Stream until Close completes.
func (*Stream) Close ¶
Close releases the underlying stream exactly once and returns the original cleanup result to sequential or concurrent callers.