Transport

Trait Transport 

Source
pub trait Transport: Send + Sync {
    // Required methods
    fn connect(&mut self) -> impl Future<Output = Result<()>> + Send;
    fn read(
        &mut self,
        buf: &mut [u8],
    ) -> impl Future<Output = Result<usize>> + Send;
    fn write(&mut self, buf: &[u8]) -> impl Future<Output = Result<()>> + Send;
    fn close(&mut self) -> impl Future<Output = Result<()>> + Send;

    // Provided method
    fn is_connected(&self) -> bool { ... }
}

Required Methods§

Source

fn connect(&mut self) -> impl Future<Output = Result<()>> + Send

Establishes a connection

§Errors

Returns an error if the connection cannot be established

Source

fn read(&mut self, buf: &mut [u8]) -> impl Future<Output = Result<usize>> + Send

Reads data into the provided buffer

§Errors

Returns an error if the read operation fails

Source

fn write(&mut self, buf: &[u8]) -> impl Future<Output = Result<()>> + Send

Writes data from the provided buffer

§Errors

Returns an error if the write operation fails

Source

fn close(&mut self) -> impl Future<Output = Result<()>> + Send

Closes the connection

§Errors

Returns an error if the connection cannot be closed cleanly

Provided Methods§

Source

fn is_connected(&self) -> bool

Checks if the transport is connected

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§