gossamer/stream
Parent module for the stream family — ReadableStream,
WritableStream, TransformStream, and their readers, writers,
and controllers. Hosts StreamLifecycleError, the shared error
type returned by stream operations that fail because of the
stream’s current state, and QueuingStrategy, the shared
backpressure-tuning type applied via stream builders.
Types
The room remaining in a stream’s internal queue, from a
desired_size accessor.
pub type DesiredSize {
Bounded(Int)
Unbounded
}
Constructors
-
Bounded(Int)Room for
nmore chunks or bytes before the queue signals backpressure. Zero or negative when the queue is at or over capacity. -
UnboundedAn unlimited strategy is in effect; the stream never signals backpressure.
The backpressure threshold applied to a stream’s internal queue.
pub type QueuingStrategy {
ByCount(high_water_mark: Int)
ByByteLength(high_water_mark: Int)
Unlimited
}
Constructors
-
ByCount(high_water_mark: Int)Backpressure measured by chunk count — the queue holds at most
high_water_markchunks before signaling pressure. -
ByByteLength(high_water_mark: Int)Backpressure measured by byte size — the queue holds at most
high_water_marktotal bytes across all chunks before signaling pressure. -
UnlimitedDisables backpressure signaling entirely. The stream accepts chunks as fast as they arrive.
Errors raised by stream lifecycle operations.
pub type StreamLifecycleError {
Locked
Closed
Errored(reason: dynamic.Dynamic)
Aborted(reason: dynamic.Dynamic)
}
Constructors
-
LockedThe stream is locked to a reader or writer. Acquiring another lock or piping a locked stream is not allowed.
-
ClosedThe stream or controller is closed. Enqueueing into or closing a closed controller is not allowed.
-
Errored(reason: dynamic.Dynamic)The stream is in an errored state.
reasonis the value the stream was errored with, either by the underlying source’s callback throwing or by the consumer explicitly erroring the controller. -
Aborted(reason: dynamic.Dynamic)A
pipe_tooperation was aborted via theAbortSignalset on itsPipeOptions. Thereasonpayload carries whatever value was passed toabort(reason)— or anAbortErrorDOMExceptionifabort()was called with no argument.