pub struct Response {
pub jsonrpc: &'static str,
pub id: Option<Value>,
pub result: Option<Value>,
pub error: Option<RpcError>,
}Expand description
A JSON-RPC response.
Fields§
§jsonrpc: &'static strJSON-RPC version.
id: Option<Value>Request ID this is responding to.
result: Option<Value>Result on success.
error: Option<RpcError>Error on failure.
Implementations§
Source§impl Response
impl Response
Sourcepub fn error(id: Option<Value>, code: i32, message: impl Into<String>) -> Self
pub fn error(id: Option<Value>, code: i32, message: impl Into<String>) -> Self
Creates an error response.
Sourcepub fn parse_error() -> Self
pub fn parse_error() -> Self
Predefined error: Parse error.
Sourcepub fn invalid_request(id: Option<Value>) -> Self
pub fn invalid_request(id: Option<Value>) -> Self
Predefined error: Invalid request.
Sourcepub fn method_not_found(id: Option<Value>, method: &str) -> Self
pub fn method_not_found(id: Option<Value>, method: &str) -> Self
Predefined error: Method not found.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Response
impl RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl UnsafeUnpin for Response
impl UnwindSafe for Response
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