pub trait HostInputStream: Send + Sync {
    // Required methods
    fn read(&mut self, size: usize) -> Result<(Bytes, StreamState), Error>;
    fn ready<'life0, 'async_trait>(
        &'life0 mut self
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn skip(&mut self, nelem: usize) -> Result<(usize, StreamState), Error> { ... }
}
Expand description

Host trait for implementing the wasi:io/streams.input-stream resource: A bytestream which can be read from.

Required Methods§

source

fn read(&mut self, size: usize) -> Result<(Bytes, StreamState), Error>

Read bytes. On success, returns a pair holding the number of bytes read and a flag indicating whether the end of the stream was reached. Important: this read must be non-blocking!

source

fn ready<'life0, 'async_trait>( &'life0 mut self ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Check for read readiness: this method blocks until the stream is ready for reading.

Provided Methods§

source

fn skip(&mut self, nelem: usize) -> Result<(usize, StreamState), Error>

Read bytes from a stream and discard them. Important: this method must be non-blocking!

Implementors§