wasmtime_wasi

Trait InputStream

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

Source

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§

Source

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.

Source

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.

Source

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.

Source

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

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

Trait Implementations§

Source§

impl Pollable for Box<dyn InputStream>

Source§

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

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

Implementors§