pub struct JsonRpcDispatcher { /* private fields */ }
Expand description
JSON-RPC method dispatcher
Implementations§
Source§impl JsonRpcDispatcher
impl JsonRpcDispatcher
pub fn new() -> Self
Sourcepub fn register_method<H>(&mut self, method: String, handler: H)where
H: JsonRpcHandler + 'static,
pub fn register_method<H>(&mut self, method: String, handler: H)where
H: JsonRpcHandler + 'static,
Register a handler for a specific method
Sourcepub fn register_methods<H>(&mut self, methods: Vec<String>, handler: H)where
H: JsonRpcHandler + 'static,
pub fn register_methods<H>(&mut self, methods: Vec<String>, handler: H)where
H: JsonRpcHandler + 'static,
Register a handler for multiple methods
Sourcepub fn set_default_handler<H>(&mut self, handler: H)where
H: JsonRpcHandler + 'static,
pub fn set_default_handler<H>(&mut self, handler: H)where
H: JsonRpcHandler + 'static,
Set a default handler for unregistered methods
Sourcepub async fn handle_request_with_context(
&self,
request: JsonRpcRequest,
session_context: SessionContext,
) -> JsonRpcResponse
pub async fn handle_request_with_context( &self, request: JsonRpcRequest, session_context: SessionContext, ) -> JsonRpcResponse
Process a JSON-RPC request with session context and return a response
Sourcepub async fn handle_request(&self, request: JsonRpcRequest) -> JsonRpcResponse
pub async fn handle_request(&self, request: JsonRpcRequest) -> JsonRpcResponse
Process a JSON-RPC request and return a response (backward compatibility - no session context)
Sourcepub async fn handle_notification(
&self,
notification: JsonRpcNotification,
) -> JsonRpcResult<()>
pub async fn handle_notification( &self, notification: JsonRpcNotification, ) -> JsonRpcResult<()>
Process a JSON-RPC notification
Sourcepub async fn handle_notification_with_context(
&self,
notification: JsonRpcNotification,
session_context: Option<SessionContext>,
) -> JsonRpcResult<()>
pub async fn handle_notification_with_context( &self, notification: JsonRpcNotification, session_context: Option<SessionContext>, ) -> JsonRpcResult<()>
Process a JSON-RPC notification with session context
Sourcepub fn registered_methods(&self) -> Vec<String>
pub fn registered_methods(&self) -> Vec<String>
Get all registered methods
Trait Implementations§
Auto Trait Implementations§
impl Freeze for JsonRpcDispatcher
impl !RefUnwindSafe for JsonRpcDispatcher
impl Send for JsonRpcDispatcher
impl Sync for JsonRpcDispatcher
impl Unpin for JsonRpcDispatcher
impl !UnwindSafe for JsonRpcDispatcher
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more