Struct jsonrpc_base::Request
source · pub struct Request {
pub jsonrpc: String,
pub id: Value,
pub method: String,
pub params: Option<Value>,
}
Expand description
JSON-RPC request
Fields§
§jsonrpc: String
Protocol header
id: Value
Request ID
method: String
Method name
params: Option<Value>
Optional method arguments
Implementations§
source§impl Request
impl Request
sourcepub fn new<M>(method: M) -> Selfwhere
M: ToString,
pub fn new<M>(method: M) -> Selfwhere M: ToString,
Create a new request with the provided method.
Will generate a random ID, if the feature uuid
is enabled. Otherwise, set the ID to 0
.
sourcepub fn with_id<I>(self, id: I) -> Selfwhere
I: Into<Number>,
pub fn with_id<I>(self, id: I) -> Selfwhere I: Into<Number>,
Replace the method ID with the provided numeric value
sourcepub fn with_id_string<I>(self, id: I) -> Selfwhere
I: ToString,
pub fn with_id_string<I>(self, id: I) -> Selfwhere I: ToString,
Replace the method ID with the provided string
sourcepub fn with_params<P>(self, params: P) -> Result<Self, Error>where
P: Serialize,
pub fn with_params<P>(self, params: P) -> Result<Self, Error>where P: Serialize,
Replace the methods arguments with the provided value
sourcepub fn with_params_value(self, params: Value) -> Self
pub fn with_params_value(self, params: Value) -> Self
Replace the methods arguments with the parsed value
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 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