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
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_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
Sourcepub fn parse(s: &str) -> Result<(Self, &str), Error>
pub fn parse(s: &str) -> Result<(Self, &str), Error>
Parse a message into the request, returning the remainder string
Sourcepub fn parse_json(json: &str) -> Result<Self, Error>
pub fn parse_json(json: &str) -> Result<Self, Error>
Parse a request from the provided JSON
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