pub struct JsonRpcRequest {
pub jsonrpc: String,
pub id: RequestId,
pub method: String,
pub params: Option<Value>,
}Expand description
JSON-RPC 2.0 request.
Fields§
§jsonrpc: StringJSON-RPC version, must be “2.0”.
id: RequestIdRequest identifier.
method: StringMethod name to invoke.
params: Option<Value>Optional parameters for the method.
Implementations§
Source§impl JsonRpcRequest
impl JsonRpcRequest
Sourcepub fn new(id: impl Into<RequestId>, method: impl Into<String>) -> Self
pub fn new(id: impl Into<RequestId>, method: impl Into<String>) -> Self
Create a new JSON-RPC request.
Sourcepub fn with_params(self, params: Value) -> Self
pub fn with_params(self, params: Value) -> Self
Add parameters to the request.
Sourcepub fn validate(&self) -> Result<(), JsonRpcError>
pub fn validate(&self) -> Result<(), JsonRpcError>
Validate that this request conforms to JSON-RPC 2.0. Returns an error if the jsonrpc version is not “2.0”.
Trait Implementations§
Source§impl Clone for JsonRpcRequest
impl Clone for JsonRpcRequest
Source§fn clone(&self) -> JsonRpcRequest
fn clone(&self) -> JsonRpcRequest
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 JsonRpcRequest
impl Debug for JsonRpcRequest
Source§impl<'de> Deserialize<'de> for JsonRpcRequest
impl<'de> Deserialize<'de> for JsonRpcRequest
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
Source§impl Serialize for JsonRpcRequest
impl Serialize for JsonRpcRequest
Source§impl<S> Service<JsonRpcRequest> for JsonRpcService<S>where
S: Service<RouterRequest, Response = RouterResponse, Error = Infallible> + Clone + Send + 'static,
S::Future: Send,
impl<S> Service<JsonRpcRequest> for JsonRpcService<S>where
S: Service<RouterRequest, Response = RouterResponse, Error = Infallible> + Clone + Send + 'static,
S::Future: Send,
Source§type Response = JsonRpcResponse
type Response = JsonRpcResponse
Responses given by the service.
Source§type Future = Pin<Box<dyn Future<Output = Result<<JsonRpcService<S> as Service<JsonRpcRequest>>::Response, <JsonRpcService<S> as Service<JsonRpcRequest>>::Error>> + Send>>
type Future = Pin<Box<dyn Future<Output = Result<<JsonRpcService<S> as Service<JsonRpcRequest>>::Response, <JsonRpcService<S> as Service<JsonRpcRequest>>::Error>> + Send>>
The future response value.
Auto Trait Implementations§
impl Freeze for JsonRpcRequest
impl RefUnwindSafe for JsonRpcRequest
impl Send for JsonRpcRequest
impl Sync for JsonRpcRequest
impl Unpin for JsonRpcRequest
impl UnwindSafe for JsonRpcRequest
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