pub trait Dispatch: Send + Sync {
// Required methods
fn authenticate<'a>(
&'a self,
peer: &'a PeerInfo,
first: Option<&'a [u8]>,
) -> BoxFut<'a, Result<SessionCtx, AuthError>>;
fn open(&self, ctx: &SessionCtx) -> Box<dyn Session>;
}Expand description
The shared application dispatch: authenticate a connection, then open a
per-connection Session. One Arc<dyn Dispatch> is shared across every
accepted connection, so it stays Send + Sync and behind &self.
Required Methods§
Sourcefn authenticate<'a>(
&'a self,
peer: &'a PeerInfo,
first: Option<&'a [u8]>,
) -> BoxFut<'a, Result<SessionCtx, AuthError>>
fn authenticate<'a>( &'a self, peer: &'a PeerInfo, first: Option<&'a [u8]>, ) -> BoxFut<'a, Result<SessionCtx, AuthError>>
Resolve a SessionCtx from peer metadata and/or the first frame
(a pre-resolved identity in PeerInfo, or an in-band Hello in first).
Sourcefn open(&self, ctx: &SessionCtx) -> Box<dyn Session>
fn open(&self, ctx: &SessionCtx) -> Box<dyn Session>
Open the per-connection Session once, after authenticate. It owns
the connection’s mutable dispatch state that the shared Arc<Self> cannot
hold behind &self; the engine threads &mut into it.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".