pub struct HttpJsonRpcResponse {
pub jsonrpc: String,
pub id: Option<Value>,
pub result: Option<Value>,
pub error: Option<JsonRpcError>,
}Expand description
Lenient JSON-RPC response for HTTP boundary
Uses separate result/error fields for compatibility with various JSON-RPC implementations.
Fields§
§jsonrpc: StringJSON-RPC version
id: Option<Value>Response ID
result: Option<Value>Success result
error: Option<JsonRpcError>Error information
Implementations§
Source§impl HttpJsonRpcResponse
impl HttpJsonRpcResponse
Sourcepub fn error(id: Option<Value>, error: JsonRpcError) -> Self
pub fn error(id: Option<Value>, error: JsonRpcError) -> Self
Create an error response
Sourcepub fn error_from_code(
id: Option<Value>,
code: i32,
message: impl Into<String>,
) -> Self
pub fn error_from_code( id: Option<Value>, code: i32, message: impl Into<String>, ) -> Self
Create an error response from error code
Sourcepub fn invalid_request(id: Option<Value>, reason: impl Into<String>) -> Self
pub fn invalid_request(id: Option<Value>, reason: impl Into<String>) -> Self
Create an invalid request error response
Sourcepub fn parse_error(details: Option<String>) -> Self
pub fn parse_error(details: Option<String>) -> Self
Create a parse error response (id is always null for parse errors)
Sourcepub fn internal_error(id: Option<Value>, details: &str) -> Self
pub fn internal_error(id: Option<Value>, details: &str) -> Self
Create an internal error response
Sourcepub fn method_not_found(id: Option<Value>, method: &str) -> Self
pub fn method_not_found(id: Option<Value>, method: &str) -> Self
Create a method not found error response
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Check if this is a success response
Trait Implementations§
Source§impl Clone for HttpJsonRpcResponse
impl Clone for HttpJsonRpcResponse
Source§fn clone(&self) -> HttpJsonRpcResponse
fn clone(&self) -> HttpJsonRpcResponse
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 HttpJsonRpcResponse
impl Debug for HttpJsonRpcResponse
Source§impl<'de> Deserialize<'de> for HttpJsonRpcResponse
impl<'de> Deserialize<'de> for HttpJsonRpcResponse
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 HttpJsonRpcResponse
impl RefUnwindSafe for HttpJsonRpcResponse
impl Send for HttpJsonRpcResponse
impl Sync for HttpJsonRpcResponse
impl Unpin for HttpJsonRpcResponse
impl UnwindSafe for HttpJsonRpcResponse
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