pub trait Dispatch:
Send
+ Sync
+ 'static {
// Required methods
fn dispatch(
&self,
session: &Session,
command: &str,
args: Vec<Value>,
) -> impl Future<Output = Result<Value, String>> + Send;
fn authenticate(
&self,
creds: Credentials,
) -> impl Future<Output = Result<Principal, AuthError>> + Send;
// Provided method
fn capabilities(&self, principal: &Principal) -> 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 Methods§
Sourcefn dispatch(
&self,
session: &Session,
command: &str,
args: Vec<Value>,
) -> impl Future<Output = Result<Value, String>> + Send
fn dispatch( &self, session: &Session, 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, AuthError>> + Send
fn authenticate( &self, creds: Credentials, ) -> impl Future<Output = Result<Principal, 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§
Sourcefn capabilities(&self, principal: &Principal) -> Vec<String>
fn capabilities(&self, principal: &Principal) -> Vec<String>
Capability names advertised in MapPayload HELLO replies
(SRV-014). Defaults to none.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".