wasmtime_wasi

Trait HostInputStream

source
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§

source

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§

source

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.

source

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.

source

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.

source

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

Cancel any asynchronous work and wait for it to wrap up.

Trait Implementations§

source§

impl Subscribe for Box<dyn HostInputStream>

source§

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

An asynchronous function which resolves when this object’s readiness operation is ready. Read more

Implementors§