Struct StreamReader

Source
pub struct StreamReader<T>
where T: 'static,
{ /* private fields */ }
Expand description

Represents the readable end of a Component Model stream.

Implementations§

Source§

impl<T> StreamReader<T>

Source

pub fn read(&mut self, buf: Vec<T>) -> StreamRead<'_, T>

Starts a new read operation on this stream into buf.

This method will read values into the spare capacity of the buf provided. If buf has no spare capacity then this will be equivalent to a zero-length read.

Upon completion the buf will be yielded back to the caller via the completion of the StreamRead future.

§Cancellation

Cancelling the returned future can be done with drop like all Rust futures, but it does not mean that no values were read. To accurately determine if values were read the StreamRead::cancel method must be used.

Source

pub async fn next(&mut self) -> Option<T>

Reads a single item from this stream.

This is a higher-level method than StreamReader::read in that it reads only a single item and does not expose control over cancellation.

Source

pub async fn collect(self) -> Vec<T>

Reads all items from this stream and returns the list.

This method will read all remaining items from this stream into a list and await the stream to be dropped.

Trait Implementations§

Source§

impl<T> Debug for StreamReader<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<T> Drop for StreamReader<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<T> !Freeze for StreamReader<T>

§

impl<T> RefUnwindSafe for StreamReader<T>

§

impl<T> Send for StreamReader<T>

§

impl<T> Sync for StreamReader<T>

§

impl<T> Unpin for StreamReader<T>

§

impl<T> UnwindSafe for StreamReader<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.