pub enum JsonRpc {
Request(Request),
Notification(Notification),
Success(Success),
Error(Error),
}
Expand description
JSON-RPC 2.0 Request object and Response object JSON-RPC 2.0 Specification.
This enum represents all possible JSON-RPC message types:
- Request: A method call with an identifier
- Notification: A method call without an identifier (no response expected)
- Success: A successful response to a request
- Error: An error response to a request
Variants§
Request(Request)
Request object
Notification(Notification)
Notification object
Success(Success)
Success Response
Error(Error)
Error Response
Implementations§
Source§impl JsonRpc
impl JsonRpc
Sourcepub fn request_with_params<I: Into<Id>, P: Into<Params>>(
id: I,
method: &str,
params: P,
) -> Self
pub fn request_with_params<I: Into<Id>, P: Into<Params>>( id: I, method: &str, params: P, ) -> Self
Sourcepub fn notification(method: &str) -> Self
pub fn notification(method: &str) -> Self
Sourcepub fn notification_with_params<P: Into<Params>>(
method: &str,
params: P,
) -> Self
pub fn notification_with_params<P: Into<Params>>( method: &str, params: P, ) -> Self
Sourcepub fn get_version(&self) -> Option<&str>
pub fn get_version(&self) -> Option<&str>
Gets the JSON-RPC protocol version
§Returns
The protocol version string (“2.0”) or None if not available
Sourcepub fn get_id(&self) -> Option<Id>
pub fn get_id(&self) -> Option<Id>
Gets the identifier from the JSON-RPC message
§Returns
The identifier if present (for requests and responses), or None for notifications
Sourcepub fn get_method(&self) -> Option<&str>
pub fn get_method(&self) -> Option<&str>
Gets the method name from the JSON-RPC message
§Returns
The method name if present (for requests and notifications), or None for responses
Sourcepub fn get_params(&self) -> Option<Params>
pub fn get_params(&self) -> Option<Params>
Gets the parameters from the JSON-RPC message
§Returns
The parameters if present (for requests and notifications), or None for responses
Sourcepub fn get_result(&self) -> Option<&Value>
pub fn get_result(&self) -> Option<&Value>
Gets the result from a successful JSON-RPC response
§Returns
The result if this is a success response, or None otherwise
Sourcepub fn get_error(&self) -> Option<&RpcError>
pub fn get_error(&self) -> Option<&RpcError>
Gets the error from an error JSON-RPC response
§Returns
The error if this is an error response, or None otherwise