RKTK API Docs RKTK Home Repo

Trait SplitDriver

Source
pub trait SplitDriver: 'static {
    type Error: Error;

    // Required methods
    async fn recv(
        &mut self,
        buf: &mut [u8],
        is_master: bool,
    ) -> Result<usize, Self::Error>;
    async fn send_all(
        &mut self,
        buf: &[u8],
        is_master: bool,
    ) -> Result<(), Self::Error>;

    // Provided method
    async fn init(&mut self) -> Result<(), Self::Error> { ... }
}

Required Associated Types§

Required Methods§

Source

async fn recv( &mut self, buf: &mut [u8], is_master: bool, ) -> Result<usize, Self::Error>

Receive data from the other side and return the number of bytes received.

If there is no data, this function should wait until data is received.

Source

async fn send_all( &mut self, buf: &[u8], is_master: bool, ) -> Result<(), Self::Error>

Send data to the other side.

Implemention should wait until the all data is sent.

Provided Methods§

Source

async fn init(&mut self) -> Result<(), Self::Error>

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.

Implementors§