gossamer/stream/writable_stream/writer
The push-side cursor over a WritableStream. Acquire one with
gossamer/stream/writable_stream.get_writer
then call write to send chunks. Release the lock via
release_lock when done.
Types
A JavaScript WritableStreamDefaultWriter — a locked writer over
a WritableStream.
See WritableStreamDefaultWriter on MDN.
pub type Writer(a)
Values
pub fn abort(
writer: Writer(a),
reason reason: r,
) -> promise.Promise(Result(Nil, stream.StreamLifecycleError))
Aborts the stream. Returns Errored if the underlying sink’s
abort callback throws or returns a rejecting promise.
pub fn close(
writer: Writer(a),
) -> promise.Promise(Result(Nil, stream.StreamLifecycleError))
Closes the stream after all writes complete. Returns Errored if
the underlying sink’s close callback throws or returns a rejecting
promise, or if the stream is already closing or closed.
pub fn closed(
writer: Writer(a),
) -> promise.Promise(Result(Nil, stream.StreamLifecycleError))
Resolves when the stream closes. Returns Errored if the stream
enters an errored state, or if the writer no longer holds the lock;
the reason payload distinguishes the two.
pub fn desired_size(
writer: Writer(a),
) -> Result(stream.DesiredSize, Nil)
The room remaining in the stream’s internal queue. Returns an error
if the stream has errored or is erroring, or if the writer’s lock
has been released; a closed stream reports Bounded(0).
pub fn ready(
writer: Writer(a),
) -> promise.Promise(Result(Nil, stream.StreamLifecycleError))
Resolves when the stream is ready to accept more writes
(backpressure has cleared). Returns Errored if the stream enters
an errored state.
pub fn release_lock(writer: Writer(a)) -> Nil
Releases the writer’s lock on the stream.
pub fn write(
to writer: Writer(a),
chunk chunk: a,
) -> promise.Promise(Result(Nil, stream.StreamLifecycleError))
Writes chunk to the stream. Returns Errored if the stream
enters an errored state, or if the stream was already closed when
write was called; the reason payload distinguishes the two.