gossamer/stream/transform_stream/default_controller

The controller passed to a TransformStream’s transformer callbacks. Use it to emit chunks to the readable side via enqueue, error the stream with error, or end transformation with terminate.

Types

A JavaScript TransformStreamDefaultController — passed to a TransformStream’s transformer callbacks. Used to enqueue output chunks, signal errors, or terminate the stream.

See TransformStreamDefaultController on MDN.

pub type DefaultController(a)

Values

pub fn desired_size(
  controller: DefaultController(a),
) -> Result(stream.DesiredSize, Nil)

The room remaining in the readable side’s internal queue. Returns an error if the stream has errored; a closed stream reports Bounded(0).

pub fn enqueue(
  in controller: DefaultController(a),
  chunk chunk: a,
) -> Result(Nil, stream.StreamLifecycleError)

Enqueues chunk into the readable side’s internal queue. Returns Closed if the stream is already closed or errored.

pub fn error(
  controller: DefaultController(a),
  reason reason: b,
) -> Nil

Signals an error on the stream. A no-op if the stream is already closed or errored.

pub fn terminate(controller: DefaultController(a)) -> Nil

Closes the readable side and errors the writable side of the stream. A no-op if the stream is already closed or terminated.

Search Document