pub trait HostInputStream: Subscribe {
// Required method
fn read(&mut self, size: usize) -> StreamResult<Bytes>;
// Provided methods
fn blocking_read<'life0, 'async_trait>(
&'life0 mut self,
size: usize,
) -> Pin<Box<dyn Future<Output = StreamResult<Bytes>> + Send + 'async_trait>>
where Self: Send + 'async_trait,
'life0: 'async_trait { ... }
fn skip(&mut self, nelem: usize) -> StreamResult<usize> { ... }
fn blocking_skip<'life0, 'async_trait>(
&'life0 mut self,
nelem: usize,
) -> Pin<Box<dyn Future<Output = StreamResult<usize>> + Send + 'async_trait>>
where Self: Send + 'async_trait,
'life0: 'async_trait { ... }
fn cancel<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Send + 'async_trait,
'life0: 'async_trait { ... }
}
Expand description
Host trait for implementing the wasi:io/streams.input-stream
resource: A
bytestream which can be read from.
Required Methods§
sourcefn read(&mut self, size: usize) -> StreamResult<Bytes>
fn read(&mut self, size: usize) -> StreamResult<Bytes>
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§
sourcefn blocking_read<'life0, 'async_trait>(
&'life0 mut self,
size: usize,
) -> Pin<Box<dyn Future<Output = StreamResult<Bytes>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
fn blocking_read<'life0, 'async_trait>(
&'life0 mut self,
size: usize,
) -> Pin<Box<dyn Future<Output = StreamResult<Bytes>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
Similar to read
, except that it blocks until at least one byte can be
read.
sourcefn skip(&mut self, nelem: usize) -> StreamResult<usize>
fn skip(&mut self, nelem: usize) -> StreamResult<usize>
Same as the read
method except that bytes are skipped.
Note that this method is non-blocking like read
and returns the same
errors.
sourcefn blocking_skip<'life0, 'async_trait>(
&'life0 mut self,
nelem: usize,
) -> Pin<Box<dyn Future<Output = StreamResult<usize>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
fn blocking_skip<'life0, 'async_trait>(
&'life0 mut self,
nelem: usize,
) -> Pin<Box<dyn Future<Output = StreamResult<usize>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
Similar to skip
, except that it blocks until at least one byte can be
skipped.