Struct wasm_streams::readable::ReadableStream[][src]

pub struct ReadableStream { /* fields omitted */ }
Expand description

A ReadableStream.

ReadableStreams can be created from a raw JavaScript stream with from_raw, or from a Rust Stream with from_stream.

They can be converted into a raw JavaScript stream with into_raw, or into a Rust Stream with into_stream.

If the browser supports readable byte streams, then they can be created from a Rust AsyncRead with from_async_read, or converted into one with into_async_read.

Implementations

Creates a new ReadableStream from a JavaScript stream.

Creates a new ReadableStream from a Stream.

Items and errors must be represented as raw JsValues. Use map, map_ok and/or map_err to convert a stream’s items to a JsValue before passing it to this function.

Creates a new ReadableStream from an AsyncRead.

This creates a readable byte stream whose autoAllocateChunkSize is default_buffer_len. Therefore, if a default reader is used to consume the stream, the given async_read will be polled with a buffer of this size. If a BYOB reader is used, then it will be polled with a buffer of the same size as the BYOB read request instead.

Panics if readable byte streams are not supported by the browser.

Acquires a reference to the underlying JavaScript stream.

Consumes this ReadableStream, returning the underlying JavaScript stream.

Returns true if the stream is locked to a reader.

Cancels the stream, signaling a loss of interest in the stream by a consumer.

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

Cancels the stream, signaling a loss of interest in the stream by a consumer.

The supplied reason will be given to the underlying source, which may or may not use it.

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

Creates a default reader and locks the stream to the new reader.

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

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

Try to create a default reader and lock the stream to the new reader.

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

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

Creates a BYOB reader and locks the stream to the new reader.

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

Panics if the stream is already locked to a reader, or if this stream is not a readable byte stream. For a non-panicking variant, use try_get_reader.

Try to create a BYOB reader and lock the stream to the new reader.

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

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

Pipes this readable stream to a given writable stream.

Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.

This returns () if the pipe completes successfully, or Err(error) if any error was encountered during the process.

Pipes this readable stream to a given writable stream.

Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.

Errors and closures of the source and destination streams propagate as follows:

  • An error in the source readable stream will abort the destination writable stream, unless options.prevent_abort is true.
  • An error in the destination writable stream will cancel the source readable stream, unless options.prevent_cancel is true.
  • When the source readable stream closes, the destination writable stream will be closed, unless options.prevent_close is true.
  • If the destination writable stream starts out closed or closing, the source readable stream will be canceled, unless unless options.prevent_cancel is true.

This returns () if the pipe completes successfully, or Err(error) if any error was encountered during the process.

Tees this readable stream, returning the two resulting branches as new ReadableStream instances.

Teeing a stream will lock it, preventing any other consumer from acquiring a reader. To cancel the stream, cancel both of the resulting branches; a composite cancellation reason will then be propagated to the stream’s underlying source.

Note that the chunks seen in each branch will be the same object. If the chunks are not immutable, this could allow interference between the two branches.

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

Tries to tee this readable stream, returning the two resulting branches as new ReadableStream instances.

Teeing a stream will lock it, preventing any other consumer from acquiring a reader. To cancel the stream, cancel both of the resulting branches; a composite cancellation reason will then be propagated to the stream’s underlying source.

Note that the chunks seen in each branch will be the same object. If the chunks are not immutable, this could allow interference between the two branches.

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

Converts this ReadableStream into a Stream.

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

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

Try to convert this ReadableStream into a Stream.

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

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

Converts this ReadableStream into an AsyncRead.

Panics if the stream is already locked to a reader, or if this stream is not a readable byte stream. For a non-panicking variant, use try_into_async_read.

Try to convert this ReadableStream into an AsyncRead.

If the stream is already locked to a reader, or if this stream is not a readable byte stream, then this returns an error along with the original ReadableStream.

Trait Implementations

Formats the value using the given formatter. Read more

Equivalent to from_stream.

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

Performs the conversion.

Performs the conversion.

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.