pub struct Request { /* private fields */ }
Expand description
JSON-RPC request.
Implementations
sourceimpl Request
impl Request
sourcepub fn new(id: Option<Value>, method: String, params: Option<Value>) -> Self
pub fn new(id: Option<Value>, method: String, params: Option<Value>) -> Self
Create a new request.
sourcepub fn new_reply(method: &str, params: Option<Value>) -> Self
pub fn new_reply(method: &str, params: Option<Value>) -> Self
Create a new request that expects a reply.
A random number is generated for the message id.
sourcepub fn new_notification(method: &str, params: Option<Value>) -> Self
pub fn new_notification(method: &str, params: Option<Value>) -> Self
Create a new notification.
The id field is None
.
sourcepub fn id_mut(&mut self) -> &mut Option<Value>
pub fn id_mut(&mut self) -> &mut Option<Value>
The mutable id for the request if you need to take it to assign to response.
sourcepub fn matches(&self, name: &str) -> bool
👎 Deprecated: Use match expression on method() instead
pub fn matches(&self, name: &str) -> bool
Use match expression on method() instead
Determine if the given name matches the request method.
sourcepub fn deserialize<T: DeserializeOwned>(&self) -> Result<T>
pub fn deserialize<T: DeserializeOwned>(&self) -> Result<T>
Deserialize and consume the message parameters into type T
.
If this request message has no parameters or the params
payload cannot be converted to T
this will return
Error::InvalidParams
.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Request
impl<'de> Deserialize<'de> for Request
sourcefn 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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more