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 n more chunks or bytes before the queue signals backpressure. Zero or negative when the queue is at or over capacity.

  • Unbounded

    An 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_mark chunks before signaling pressure.

  • ByByteLength(high_water_mark: Int)

    Backpressure measured by byte size — the queue holds at most high_water_mark total bytes across all chunks before signaling pressure.

  • Unlimited

    Disables 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

  • Locked

    The stream is locked to a reader or writer. Acquiring another lock or piping a locked stream is not allowed.

  • Closed

    The 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. reason is 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_to operation was aborted via the AbortSignal set on its PipeOptions. The reason payload carries whatever value was passed to abort(reason) — or an AbortError DOMException if abort() was called with no argument.

Search Document