Skip to main content

Session

Trait Session 

Source
pub trait Session<P: Protocol>: Send + Sync {
    type ClientLane: ClientTransport<P>;
    type ServiceLane: ServiceTransport<P>;

    // Required methods
    fn capabilities(&self) -> Capabilities;
    fn open_lane<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Self::ClientLane, SessionError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn accept_lane<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Self::ServiceLane, SessionError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn close<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn context(&self) -> Context { ... }
}
Expand description

An association with a peer, from which lanes are obtained.

r[impl jetstream.session.trait] Opening and accepting are fallible and asynchronous, and both take &self: a session is usable from several tasks at once, and opening a lane never requires exclusive access to the session.

r[impl jetstream.session.symmetric] Where the transport is symmetric either peer may open a lane, and the opener is the RPC caller on it. That is why the two directions have different lane types: Session::open_lane yields the caller’s end, Session::accept_lane the callee’s.

Required Associated Types§

Source

type ClientLane: ClientTransport<P>

The end of a lane this peer opened, driven as the RPC caller.

Source

type ServiceLane: ServiceTransport<P>

The end of a lane the peer opened, served as the RPC callee.

Required Methods§

Source

fn capabilities(&self) -> Capabilities

What this session can do.

r[impl jetstream.session.capabilities]

Source

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

Open a new lane and take the caller’s end of it.

Source

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

Wait for the peer to open a lane and take the callee’s end of it.

Source

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

Close the session.

r[impl jetstream.session.lifetime] Every lane opened on the session terminates, and calls in flight on those lanes fail rather than hang. Closing a lane does not close its session.

Provided Methods§

Source

fn context(&self) -> Context

The peer’s identity, in the form the transport established it.

r[impl jetstream.session.identity]

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§