FramedConnection

Trait FramedConnection 

Source
pub trait FramedConnection:
    Send
    + Sync
    + Debug {
    // Required methods
    fn send_frame<'life0, 'async_trait>(
        &'life0 self,
        data: Bytes,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn recv_frame<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn close<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn send_frame_with_fds<'life0, 'life1, 'async_trait>(
        &'life0 self,
        data: Bytes,
        fds: &'life1 [RawFd],
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn recv_frame_with_fds<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Option<(Bytes, Vec<RawFd>)>, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

A framed, length-delimited, duplex connection. Multiplexing is layered above this.

Required Methods§

Source

fn send_frame<'life0, 'async_trait>( &'life0 self, data: Bytes, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Send one frame.

Source

fn recv_frame<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Receive one frame. Returns None on EOF.

Source

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

Close half or full connection gracefully.

Provided Methods§

Source

fn send_frame_with_fds<'life0, 'life1, 'async_trait>( &'life0 self, data: Bytes, fds: &'life1 [RawFd], ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Send one frame with file descriptors (Unix SCM_RIGHTS).

On platforms that don’t support FD passing, this returns an error if any FDs are provided.

Source

fn recv_frame_with_fds<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<(Bytes, Vec<RawFd>)>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Receive one frame with file descriptors (Unix SCM_RIGHTS).

Returns the frame and any received FDs. On platforms that don’t support FD passing, the FD vec will always be empty.

Implementations on Foreign Types§

Source§

impl<T: FramedConnection + ?Sized> FramedConnection for Arc<T>

Blanket implementation of FramedConnection for Arc<T> where T implements FramedConnection. This allows wrapping connections in Arc for cloning while still using the trait methods.

Source§

fn send_frame<'life0, 'async_trait>( &'life0 self, data: Bytes, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn recv_frame<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

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

Source§

fn send_frame_with_fds<'life0, 'life1, 'async_trait>( &'life0 self, data: Bytes, fds: &'life1 [RawFd], ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn recv_frame_with_fds<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<(Bytes, Vec<RawFd>)>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Implementors§