pub struct JsonRpcResponse {
pub jsonrpc: String,
pub id: RequestId,
pub result: Option<Value>,
pub error: Option<ControlError>,
}Expand description
A JSON-RPC 2.0 response: exactly one of result or error is present.
Modelled as two Option fields (matching the wire) rather than an enum, because dig-node emits
the flat {jsonrpc, id, result} / {jsonrpc, id, error} shapes and clients read them directly.
Fields§
§jsonrpc: StringAlways "2.0".
id: RequestIdThe id echoed from the request.
result: Option<Value>The success result (present iff error is absent).
error: Option<ControlError>The error (present iff result is absent).
Implementations§
Source§impl JsonRpcResponse
impl JsonRpcResponse
Sourcepub fn success(id: RequestId, result: Value) -> JsonRpcResponse
pub fn success(id: RequestId, result: Value) -> JsonRpcResponse
Build a success response carrying result.
Sourcepub fn error(id: RequestId, error: ControlError) -> JsonRpcResponse
pub fn error(id: RequestId, error: ControlError) -> JsonRpcResponse
Build an error response carrying error.
Sourcepub fn into_result(self) -> Result<Value, ControlError>
pub fn into_result(self) -> Result<Value, ControlError>
The result value if this is a success, else the ControlError.
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 (const: unstable) · 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
impl Eq for JsonRpcResponse
Source§impl PartialEq for JsonRpcResponse
impl PartialEq for JsonRpcResponse
Source§impl Serialize for JsonRpcResponse
impl Serialize for JsonRpcResponse
impl StructuralPartialEq for JsonRpcResponse
Auto Trait Implementations§
impl Freeze for JsonRpcResponse
impl RefUnwindSafe for JsonRpcResponse
impl Send for JsonRpcResponse
impl Sync for JsonRpcResponse
impl Unpin for JsonRpcResponse
impl UnsafeUnpin 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