pub struct JsonRpcHandler { /* private fields */ }Expand description
Handles JSON-RPC 2.0 protocol communication
Implementations§
Source§impl JsonRpcHandler
impl JsonRpcHandler
Sourcepub fn next_request_id(&self) -> RequestId
pub fn next_request_id(&self) -> RequestId
Generate the next request ID
Sourcepub fn create_request(
&self,
method: impl Into<String>,
params: Option<Value>,
) -> JsonRpcRequest
pub fn create_request( &self, method: impl Into<String>, params: Option<Value>, ) -> JsonRpcRequest
Create a JSON-RPC request
Sourcepub fn create_notification(
&self,
method: impl Into<String>,
params: Option<Value>,
) -> JsonRpcNotification
pub fn create_notification( &self, method: impl Into<String>, params: Option<Value>, ) -> JsonRpcNotification
Create a JSON-RPC notification (no response expected)
Sourcepub fn serialize_request(&self, request: &JsonRpcRequest) -> Result<String>
pub fn serialize_request(&self, request: &JsonRpcRequest) -> Result<String>
Serialize a request to JSON
Sourcepub fn serialize_notification(
&self,
notification: &JsonRpcNotification,
) -> Result<String>
pub fn serialize_notification( &self, notification: &JsonRpcNotification, ) -> Result<String>
Serialize a notification to JSON
Sourcepub fn parse_response(&self, json: &str) -> Result<JsonRpcResponse>
pub fn parse_response(&self, json: &str) -> Result<JsonRpcResponse>
Parse a JSON-RPC response
Sourcepub fn parse_notification(&self, json: &str) -> Result<JsonRpcNotification>
pub fn parse_notification(&self, json: &str) -> Result<JsonRpcNotification>
Parse a JSON-RPC notification
Sourcepub fn parse_message(&self, json: &str) -> Result<JsonRpcMessage>
pub fn parse_message(&self, json: &str) -> Result<JsonRpcMessage>
Parse a JSON-RPC message (can be response or notification)
Sourcepub fn is_error_response(response: &JsonRpcResponse) -> bool
pub fn is_error_response(response: &JsonRpcResponse) -> bool
Check if a response indicates an error
Sourcepub fn extract_error_message(response: &JsonRpcResponse) -> Option<String>
pub fn extract_error_message(response: &JsonRpcResponse) -> Option<String>
Extract error message from response
Sourcepub fn create_error_response(
id: RequestId,
code: i32,
message: impl Into<String>,
) -> JsonRpcResponse
pub fn create_error_response( id: RequestId, code: i32, message: impl Into<String>, ) -> JsonRpcResponse
Create a JSON-RPC error response
Trait Implementations§
Auto Trait Implementations§
impl Freeze for JsonRpcHandler
impl RefUnwindSafe for JsonRpcHandler
impl Send for JsonRpcHandler
impl Sync for JsonRpcHandler
impl Unpin for JsonRpcHandler
impl UnwindSafe for JsonRpcHandler
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