[−][src]Struct wasm_streams::readable::ReadableStreamDefaultReader
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
impl<'stream> ReadableStreamDefaultReader<'stream>
[src]
pub fn as_raw(&self) -> &ReadableStreamDefaultReader
[src]
Acquires a reference to the underlying JavaScript reader.
pub async fn closed<'_>(&'_ self) -> Result<(), JsValue>
[src]
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.
pub async fn cancel<'_>(&'_ mut self) -> Result<(), JsValue>
[src]
Cancels the stream, signaling a loss of interest in the stream by a consumer.
Equivalent to ReadableStream.cancel
.
pub async fn cancel_with_reason<'_, '_>(
&'_ mut self,
reason: &'_ JsValue
) -> Result<(), JsValue>
[src]
&'_ mut self,
reason: &'_ JsValue
) -> Result<(), JsValue>
Cancels the stream, signaling a loss of interest in the stream by a consumer.
Equivalent to ReadableStream.cancel_with_reason
.
pub async fn read<'_>(&'_ mut self) -> Result<Option<JsValue>, JsValue>
[src]
Reads the next chunk from the stream's internal queue.
- If a next
chunk
becomes available, this returnsOk(Some(chunk))
. - If the stream closes and no more chunks are available, this returns
Ok(None)
. - If the stream encounters an
error
, this returnsErr(error)
.
pub fn release_lock(self)
[src]
Releases this reader's lock on the corresponding stream.
Panics if the reader still has a pending read request, i.e. if a future returned
by read
is not yet ready. For a non-panicking variant,
use try_release_lock
.
pub fn try_release_lock(self) -> Result<(), (Error, Self)>
[src]
Try to release this reader's lock on the corresponding stream.
The lock cannot be released while the reader still has a pending read request, i.e.
if a future returned by read
is not yet ready. Attempting to do so will
return an error and leave the reader locked to the stream.
pub fn into_stream(self) -> IntoStream<'stream>
[src]
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
impl<'stream> Debug for ReadableStreamDefaultReader<'stream>
[src]
impl<'_> Drop for ReadableStreamDefaultReader<'_>
[src]
Auto Trait Implementations
impl<'stream> RefUnwindSafe for ReadableStreamDefaultReader<'stream>
impl<'stream> !Send for ReadableStreamDefaultReader<'stream>
impl<'stream> !Sync for ReadableStreamDefaultReader<'stream>
impl<'stream> Unpin for ReadableStreamDefaultReader<'stream>
impl<'stream> !UnwindSafe for ReadableStreamDefaultReader<'stream>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,