Trait Session

Source
pub trait Session: Send + Sync {
    // Required methods
    fn send<'life0, 'life1, 'async_trait>(
        &'life0 self,
        msg: &'life1 Message,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn recv<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Message>, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn client_handshake<'life0, 'async_trait>(
        &'life0 self,
        hello: Hello,
    ) -> Pin<Box<dyn Future<Output = Result<CapabilitySet, Error>> + Send + 'async_trait>>
       where Self: Sized + 'async_trait,
             'life0: 'async_trait { ... }
    fn server_handshake<'life0, 'life1, 'life2, 'async_trait, V, R>(
        &'life0 self,
        validator: &'life1 V,
        router: &'life2 R,
        connection_id: ConnectionId,
    ) -> Pin<Box<dyn Future<Output = Result<CapabilitySet, Error>> + Send + 'async_trait>>
       where Self: Sized + 'async_trait,
             V: 'async_trait + TokenValidator,
             R: 'async_trait + Router,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
}
Expand description

A higher-level session that speaks the Message protocol over a FramedConnection.

Required Methods§

Source

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

Send a structured message.

Source

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

Receive the next structured message (deserializing from frames). None on EOF.

Provided Methods§

Source

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

Client-side handshake helper.

Sends Hello and waits for HelloOk or HelloErr. Returns bound capability set on success. Avoids panics; errors map to Error.

Source

fn server_handshake<'life0, 'life1, 'life2, 'async_trait, V, R>( &'life0 self, validator: &'life1 V, router: &'life2 R, connection_id: ConnectionId, ) -> Pin<Box<dyn Future<Output = Result<CapabilitySet, Error>> + Send + 'async_trait>>
where Self: Sized + 'async_trait, V: 'async_trait + TokenValidator, R: 'async_trait + Router, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Server-side handshake helper.

Waits for Hello, validates the token, replies with HelloOk/HelloErr, and registers the connection on success.

Implementors§

Source§

impl<T> Session for FramedSession<T>
where T: FramedConnection + Clone + 'static,