pub struct RawStreamReader<O: StreamOps> { /* private fields */ }async only.Expand description
Represents the readable end of a Component Model stream.
Implementations§
Source§impl<O: StreamOps> RawStreamReader<O>
impl<O: StreamOps> RawStreamReader<O>
Sourcepub fn handle(&self) -> u32
pub fn handle(&self) -> u32
Returns the index of the component-model handle that this stream is using.
Sourcepub fn read(&mut self, buf: Vec<O::Payload>) -> RawStreamRead<'_, O> ⓘ
pub fn read(&mut self, buf: Vec<O::Payload>) -> RawStreamRead<'_, O> ⓘ
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<O::Payload>
pub async fn next(&mut self) -> Option<O::Payload>
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.