Skip to main content

IoCapability

Trait IoCapability 

Source
pub trait IoCapability {
    type Handle: Send;
    type Reader: Send + Unpin;
    type Writer: Send + Unpin;
    type Error: Into<GuestError>;

    // Required methods
    fn new_writer(
        &self,
        handle: &Self::Handle,
    ) -> Result<Self::Writer, Self::Error>;
    fn new_reader(
        &self,
        handle: &Self::Handle,
    ) -> Result<Self::Reader, Self::Error>;
    fn read(
        &self,
        reader: &mut Self::Reader,
        len: usize,
    ) -> impl Future<Output = Result<IoFrame, Self::Error>> + Send;
    fn write(
        &self,
        writer: &mut Self::Writer,
        bytes: &[u8],
    ) -> impl Future<Output = Result<(), Self::Error>> + Send;
}
Expand description

The capabilities that any subsystem implementation needs to provide

Required Associated Types§

Required Methods§

Source

fn new_writer(&self, handle: &Self::Handle) -> Result<Self::Writer, Self::Error>

Create a new writer for the given handle

Source

fn new_reader(&self, handle: &Self::Handle) -> Result<Self::Reader, Self::Error>

Create a new reader for the given handle

Source

fn read( &self, reader: &mut Self::Reader, len: usize, ) -> impl Future<Output = Result<IoFrame, Self::Error>> + Send

Read up to len bytes

Source

fn write( &self, writer: &mut Self::Writer, bytes: &[u8], ) -> impl Future<Output = Result<(), Self::Error>> + Send

Write the given bytes

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T> IoCapability for Arc<T>
where T: IoCapability,

Source§

type Handle = <T as IoCapability>::Handle

Source§

type Reader = <T as IoCapability>::Reader

Source§

type Writer = <T as IoCapability>::Writer

Source§

type Error = <T as IoCapability>::Error

Source§

fn new_reader(&self, handle: &Self::Handle) -> Result<Self::Reader, Self::Error>

Source§

fn new_writer(&self, handle: &Self::Handle) -> Result<Self::Writer, Self::Error>

Source§

fn read( &self, reader: &mut Self::Reader, len: usize, ) -> impl Future<Output = Result<IoFrame, Self::Error>>

Source§

fn write( &self, writer: &mut Self::Writer, bytes: &[u8], ) -> impl Future<Output = Result<(), Self::Error>>

Implementors§