pub struct WritableStream { /* private fields */ }
Expand description

A WritableStream.

WritableStreams can be created from a raw JavaScript stream with from_raw, or from a Rust Sink with from_sink.

They can be converted into a raw JavaScript stream with into_raw, or into a Rust Sink with into_sink.

Implementations

Creates a new WritableStream from a JavaScript stream.

Creates a new WritableStream from a Sink.

Items and errors must be represented as raw JsValues. Use with and/or sink_map_err to convert a sink’s items to a JsValue before passing it to this function.

Acquires a reference to the underlying JavaScript stream.

Consumes this WritableStream, returning the underlying JavaScript stream.

Returns true if the stream is locked to a writer.

Aborts the stream, signaling that the producer can no longer successfully write to the stream and it is to be immediately moved to an errored state, with any queued-up writes discarded.

If the stream is currently locked to a writer, then this returns an error.

Aborts the stream with the given reason, signaling that the producer can no longer successfully write to the stream and it is to be immediately moved to an errored state, with any queued-up writes discarded.

If the stream is currently locked to a writer, then this returns an error.

Creates a writer and locks the stream to the new writer.

While the stream is locked, no other writer can be acquired until this one is released.

Panics if the stream is already locked to a writer. For a non-panicking variant, use try_get_writer.

Try to create a writer and lock the stream to the new writer.

While the stream is locked, no other writer can be acquired until this one is released.

If the stream is already locked to a writer, then this returns an error.

Converts this WritableStream into a Sink.

Items and errors are represented by their raw JsValue. Use with and/or sink_map_err on the returned stream to convert them to a more appropriate type.

Panics if the stream is already locked to a writer. For a non-panicking variant, use try_into_sink.

Try to convert this WritableStream into a Sink.

Items and errors are represented by their raw JsValue. Use with and/or sink_map_err on the returned stream to convert them to a more appropriate type.

If the stream is already locked to a writer, then this returns an error along with the original WritableStream.

Converts this WritableStream into an AsyncWrite.

The writable stream must accept Uint8Array chunks.

Panics if the stream is already locked to a writer. For a non-panicking variant, use try_into_async_write.

Try to convert this WritableStream into an AsyncWrite.

The writable stream must accept Uint8Array chunks.

If the stream is already locked to a writer, then this returns an error along with the original WritableStream.

Trait Implementations

Formats the value using the given formatter. Read more

Equivalent to from_sink.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.