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§
Sourcetype ClientLane: ClientTransport<P>
type ClientLane: ClientTransport<P>
The end of a lane this peer opened, driven as the RPC caller.
Sourcetype ServiceLane: ServiceTransport<P>
type ServiceLane: ServiceTransport<P>
The end of a lane the peer opened, served as the RPC callee.
Required Methods§
Sourcefn capabilities(&self) -> Capabilities
fn capabilities(&self) -> Capabilities
What this session can do.
r[impl jetstream.session.capabilities]
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + 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,
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§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".