gossamer/stream/readable_stream/default_controller
The controller passed to a ReadableStream’s Start and Pull
callbacks. Use it to feed chunks into the stream via
enqueue, close it with close, or signal
failure with error.
Types
A JavaScript ReadableStreamDefaultController — passed to the
Start and Pull callbacks of a ReadableStream. Used to
enqueue chunks, close the stream, or signal an error.
See ReadableStreamDefaultController on MDN.
pub type DefaultController(a)
Values
pub fn close(
controller: DefaultController(a),
) -> Result(Nil, stream.StreamLifecycleError)
Closes the stream. Returns Closed if the stream is already
closed or errored.
pub fn desired_size(
controller: DefaultController(a),
) -> Result(stream.DesiredSize, Nil)
The room remaining in the stream’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 stream’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.