pub struct Request {
pub jsonrpc: String,
pub method: String,
pub params: Option<Value>,
pub id: Option<Value>,
}Expand description
A single JSON-RPC request object
[1] https://www.jsonrpc.org/specification#request_object
Fields§
§jsonrpc: StringThe version of the protocol. Must be "2.0". See [JSONRPC_VERSION].
method: StringName of the method to be called.
params: Option<Value>The parameters for the function call.
id: Option<Value>Identifier sent by client to match to responses. If send by the client, the server will include this, in their responses.
Implementations§
Source§impl Request
impl Request
Sourcepub fn new(method: String, params: Option<Value>, id: Option<Value>) -> Self
pub fn new(method: String, params: Option<Value>, id: Option<Value>) -> Self
Creates a new request object.
pub fn build<P, I>( method: String, params_opt: Option<&P>, id_opt: Option<&I>, ) -> Result<Self, Error>
Sourcepub fn verify(&self) -> Result<(), RpcError>
pub fn verify(&self) -> Result<(), RpcError>
Verifies the correctness of the request and either returns nothing if the request was correct, or with a
RpcError object with the appropriate error to reply with.
pub fn from_slice(d: &[u8]) -> Result<Self, Error>
pub fn to_value(&self) -> Result<Value, Error>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Request
impl<'de> Deserialize<'de> for Request
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 Request
impl RefUnwindSafe for Request
impl Send for Request
impl Sync for Request
impl Unpin for Request
impl UnwindSafe for Request
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