pub struct ReadableStreamDefaultReader<'stream> { /* private fields */ }
Expand description

A ReadableStreamDefaultReader that can be used to read chunks from a ReadableStream.

This is returned by the get_reader method.

When the reader is dropped, it automatically releases its lock.

Implementations

Acquires a reference to the underlying JavaScript reader.

Waits for the stream to become closed.

This returns an error if the stream ever errors, or if the reader’s lock is released before the stream finishes closing.

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

Equivalent to ReadableStream.cancel.

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

Equivalent to ReadableStream.cancel_with_reason.

Reads the next chunk from the stream’s internal queue.

  • If a next chunk becomes available, this returns Ok(Some(chunk)).
  • If the stream closes and no more chunks are available, this returns Ok(None).
  • If the stream encounters an error, this returns Err(error).

Releases this reader’s lock on the corresponding stream.

As of January 2022, the Streams standard allows the lock to be released even when there are still pending read requests. Such requests will automatically become rejected, and this function will always succeed.

However, if the Streams implementation is not yet up-to-date with this change, then releasing the lock while there are pending read requests will panic. For a non-panicking variant, use try_release_lock.

Try to release this reader’s lock on the corresponding stream.

As of January 2022, the Streams standard allows the lock to be released even when there are still pending read requests. Such requests will automatically become rejected, and this function will always return Ok(()).

However, if the Streams implementation is not yet up-to-date with this change, then the lock cannot be released while there are pending read requests. Attempting to do so will return an error and leave the reader locked to the stream.

Converts this ReadableStreamDefaultReader into a Stream.

This is similar to ReadableStream.into_stream, except that after the returned Stream is dropped, the original ReadableStream is still usable. This allows reading only a few chunks from the Stream, while still allowing another reader to read the remaining chunks later on.

Trait Implementations

Formats the value using the given formatter. Read more
Executes the destructor for this type. Read more

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.