Skip to main content

InboundHandler

Type Alias InboundHandler 

Source
pub type InboundHandler = Box<dyn FnMut(RawJsonRpcMessage) -> Option<Value> + Send + Sync>;
Expand description

Handler invoked by a transport for inbound messages that are not the currently awaited response.

  • Notifications (no id): the handler is called for side-effect; the return value is ignored (notifications have no reply).
  • Server→client requests (method + id, id not matching the pending request): the handler may return Some(value) to send back a JSON-RPC response; the transport serializes and writes it. Return None to leave the request unanswered (rare; usually a bug).

Send + Sync so the same trait object can be used from any task that needs to dispatch inbound messages (e.g. the HTTP POST-SSE drain in http::StreamableHttpTransport).

Aliased Type§

pub struct InboundHandler(/* private fields */);