#[non_exhaustive]pub struct Message {
pub jsonrpc: String,
pub id: Option<RequestId>,
pub method: Option<String>,
pub params: Option<Value>,
pub result: Option<Value>,
pub error: Option<JsonRpcError>,
}Expand description
An incoming JSON-RPC message.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.jsonrpc: StringAlways "2.0".
id: Option<RequestId>Optional ID — present for requests and responses, absent for notifications.
method: Option<String>Method name — present for requests and notifications, absent for responses.
params: Option<Value>Parameters — present for requests and notifications.
result: Option<Value>Result — present for successful responses.
error: Option<JsonRpcError>Error — present for failed responses.
Implementations§
Source§impl Message
impl Message
Sourcepub fn request(id: RequestId, method: impl Into<String>, params: Value) -> Self
pub fn request(id: RequestId, method: impl Into<String>, params: Value) -> Self
Construct a request with id, method, and params.
Sourcepub fn notification(method: impl Into<String>, params: Value) -> Self
pub fn notification(method: impl Into<String>, params: Value) -> Self
Construct a notification with method and params.
Sourcepub fn response(id: RequestId, result: Value) -> Self
pub fn response(id: RequestId, result: Value) -> Self
Construct a successful response carrying result.
Sourcepub fn response_error(id: RequestId, error: JsonRpcError) -> Self
pub fn response_error(id: RequestId, error: JsonRpcError) -> Self
Construct a failed response carrying error.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
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 Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnsafeUnpin for Message
impl UnwindSafe for Message
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