pub trait Router: Send + Sync {
// Required methods
fn register_connection<'life0, 'async_trait>(
&'life0 self,
ctx: ConnectionContext,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn dispatch<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 ConnectionContext,
request: Request,
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn emit_event<'life0, 'async_trait>(
&'life0 self,
event: Event,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn is_authorized(
&self,
ctx: &ConnectionContext,
method: &MethodId,
) -> Result<(), RpcError>;
// Provided method
fn observe_cancel<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 ConnectionContext,
_id: u64,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
Central router interface responsible for:
- binding connections to capability sets
- enforcing authorization
- dispatching requests to services
- emitting events
Required Methods§
Sourcefn register_connection<'life0, 'async_trait>(
&'life0 self,
ctx: ConnectionContext,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn register_connection<'life0, 'async_trait>(
&'life0 self,
ctx: ConnectionContext,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Register a new connection after handshake.
Sourcefn dispatch<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 ConnectionContext,
request: Request,
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn dispatch<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 ConnectionContext,
request: Request,
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Resolve and dispatch a request to a target service method.
Sourcefn emit_event<'life0, 'async_trait>(
&'life0 self,
event: Event,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn emit_event<'life0, 'async_trait>(
&'life0 self,
event: Event,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Emit an event to a connection or broadcast to all with appropriate policies.
Check whether a given method is allowed by a connection’s capabilities.
Provided Methods§
Sourcefn observe_cancel<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 ConnectionContext,
_id: u64,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn observe_cancel<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 ConnectionContext,
_id: u64,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Observe a cancellation request for auditing/metrics.
Implementations may ignore this. Cancellation itself is enforced by the IPC server loop via cooperative checks and/or task abort.