Trait InputStream
pub trait InputStream: Pollable {
// Required method
fn read(&mut self, size: usize) -> Result<Bytes, StreamError>;
// Provided methods
fn blocking_read<'life0, 'async_trait>(
&'life0 mut self,
size: usize,
) -> Pin<Box<dyn Future<Output = Result<Bytes, StreamError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: Send + 'async_trait { ... }
fn skip(&mut self, nelem: usize) -> Result<usize, StreamError> { ... }
fn blocking_skip<'life0, 'async_trait>(
&'life0 mut self,
nelem: usize,
) -> Pin<Box<dyn Future<Output = Result<usize, StreamError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: Send + 'async_trait { ... }
fn cancel<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: Send + 'async_trait { ... }
}Expand description
Host trait for implementing the wasi:io/streams.input-stream resource: A
bytestream which can be read from.
Required Methods§
fn read(&mut self, size: usize) -> Result<Bytes, StreamError>
fn read(&mut self, size: usize) -> Result<Bytes, StreamError>
Reads up to size bytes, returning a buffer holding these bytes on
success.
This function does not block the current thread and is the equivalent of
a non-blocking read. On success all bytes read are returned through
Bytes, which is no larger than the size provided. If the returned
list of Bytes is empty then no data is ready to be read at this time.
§Errors
The StreamError return value communicates when this stream is
closed, when a read fails, or when a trap should be generated.
Provided Methods§
fn blocking_read<'life0, 'async_trait>(
&'life0 mut self,
size: usize,
) -> Pin<Box<dyn Future<Output = Result<Bytes, StreamError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: Send + 'async_trait,
fn blocking_read<'life0, 'async_trait>(
&'life0 mut self,
size: usize,
) -> Pin<Box<dyn Future<Output = Result<Bytes, StreamError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: Send + 'async_trait,
Similar to read, except that it blocks until at least one byte can be
read.
fn skip(&mut self, nelem: usize) -> Result<usize, StreamError>
fn skip(&mut self, nelem: usize) -> Result<usize, StreamError>
Same as the read method except that bytes are skipped.
Note that this method is non-blocking like read and returns the same
errors.
fn blocking_skip<'life0, 'async_trait>(
&'life0 mut self,
nelem: usize,
) -> Pin<Box<dyn Future<Output = Result<usize, StreamError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: Send + 'async_trait,
fn blocking_skip<'life0, 'async_trait>(
&'life0 mut self,
nelem: usize,
) -> Pin<Box<dyn Future<Output = Result<usize, StreamError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: Send + 'async_trait,
Similar to skip, except that it blocks until at least one byte can be
skipped.