pub struct JsonRpcResponse {
pub jsonrpc: String,
pub result: Option<Value>,
pub error: Option<JsonRpcError>,
pub id: Option<JsonRpcId>,
}Expand description
JSON-RPC 2.0 response object
Fields§
§jsonrpc: StringProtocol version (always “2.0”)
result: Option<Value>Result on success (mutually exclusive with error)
error: Option<JsonRpcError>Error on failure (mutually exclusive with result)
id: Option<JsonRpcId>Request ID this response corresponds to
Implementations§
Source§impl JsonRpcResponse
impl JsonRpcResponse
Sourcepub fn error(error: JsonRpcError, id: Option<JsonRpcId>) -> Self
pub fn error(error: JsonRpcError, id: Option<JsonRpcId>) -> Self
Create an error response
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Check if response is successful
Sourcepub fn into_result(self) -> Result<Value, JsonRpcError>
pub fn into_result(self) -> Result<Value, JsonRpcError>
Get result, returning error if response was an error
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<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. 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