pub struct StreamReader<T: 'static> { /* private fields */ }
Expand description
Represents the readable end of a Component Model stream
.
Implementations§
Source§impl<T> StreamReader<T>
impl<T> StreamReader<T>
Sourcepub fn read(&mut self, buf: Vec<T>) -> StreamRead<'_, T> ⓘ
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.
Sourcepub async fn next(&mut self) -> Option<T>
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.
Trait Implementations§
Source§impl<T> Debug for StreamReader<T>
impl<T> Debug for StreamReader<T>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more