pub trait Dispatch:
Send
+ Sync
+ 'static {
type Identity: Send + Sync + 'static;
// Required methods
fn dispatch(
&self,
session: &Session<Self::Identity>,
command: &str,
args: Vec<Value>,
) -> impl Future<Output = Result<Value, String>> + Send;
fn authenticate(
&self,
creds: Credentials,
) -> impl Future<Output = Result<Principal<Self::Identity>, AuthError>> + Send;
// Provided method
fn capabilities(&self, principal: &Principal<Self::Identity>) -> Vec<String> { ... }
}Expand description
Product integration is exactly this trait (SRV-020).
Declared with return-position impl Future + Send so implementers can
write plain async fn (no async-trait dependency) while the listener
can still spawn dispatch futures onto the runtime. The listener is
generic over D: Dispatch, so object safety is not required.
Required Associated Types§
Sourcetype Identity: Send + Sync + 'static
type Identity: Send + Sync + 'static
The product’s own identity payload, resolved once at AUTH and
carried on the session (SRV-012).
Write type Identity = (); when the principal’s name is all the
product needs. Rust has no stable associated-type defaults, so the
line is required even in that case — the ergonomics live on
Principal and Session, which both default their parameter
to ().
Required Methods§
Sourcefn dispatch(
&self,
session: &Session<Self::Identity>,
command: &str,
args: Vec<Value>,
) -> impl Future<Output = Result<Value, String>> + Send
fn dispatch( &self, session: &Session<Self::Identity>, command: &str, args: Vec<Value>, ) -> impl Future<Output = Result<Value, String>> + Send
Run one command. The error String travels verbatim on the wire
(SRV-021, WIRE-040); a returned Err never closes the connection
(SRV-005).
Sourcefn authenticate(
&self,
creds: Credentials,
) -> impl Future<Output = Result<Principal<Self::Identity>, AuthError>> + Send
fn authenticate( &self, creds: Credentials, ) -> impl Future<Output = Result<Principal<Self::Identity>, AuthError>> + Send
Validate credentials parsed from HELLO/AUTH (SRV-012). Thunder
flips the session’s auth flag on Ok — product code never touches
the state machine.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".