pub struct JsonRpcResponse {
pub jsonrpc: JsonRpcVersion,
pub result: Option<Value>,
pub error: Option<JsonRpcError>,
pub id: Option<MessageId>,
}
Expand description
JSON-RPC response message
Fields§
§jsonrpc: JsonRpcVersion
JSON-RPC version
result: Option<Value>
Response result (success case)
error: Option<JsonRpcError>
Response error (error case)
id: Option<MessageId>
Request identifier (null for parse errors)
Implementations§
Source§impl JsonRpcResponse
impl JsonRpcResponse
Sourcepub fn success(result: Value, id: MessageId) -> JsonRpcResponse
pub fn success(result: Value, id: MessageId) -> JsonRpcResponse
Create a successful response
Sourcepub fn error(error: JsonRpcError, id: Option<MessageId>) -> JsonRpcResponse
pub fn error(error: JsonRpcError, id: Option<MessageId>) -> JsonRpcResponse
Create an error response
Sourcepub fn parse_error(message: Option<String>) -> JsonRpcResponse
pub fn parse_error(message: Option<String>) -> JsonRpcResponse
Create a parse error response (id is null)
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Check if this is a successful response
Trait Implementations§
Source§impl Clone for JsonRpcResponse
impl Clone for JsonRpcResponse
Source§fn clone(&self) -> JsonRpcResponse
fn clone(&self) -> JsonRpcResponse
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for JsonRpcResponse
impl Debug for JsonRpcResponse
Source§impl<'de> Deserialize<'de> for JsonRpcResponse
impl<'de> Deserialize<'de> for JsonRpcResponse
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<JsonRpcResponse, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<JsonRpcResponse, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for JsonRpcResponse
impl Serialize for JsonRpcResponse
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for JsonRpcResponse
impl RefUnwindSafe for JsonRpcResponse
impl Send for JsonRpcResponse
impl Sync for JsonRpcResponse
impl Unpin for JsonRpcResponse
impl UnwindSafe for JsonRpcResponse
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