pub struct RpcNotification {
pub method: String,
pub params: Option<Value>,
}Expand description
Represents a JSON-RPC Notification object, which is a request without an id.
Notifications are inherently unreliable as no response is expected.
Note: Derives Deserialize for convenience but custom parsing logic is in from_value.
Does not derive Serialize as a custom implementation is needed to add jsonrpc: "2.0".
Fields§
§method: String§params: Option<Value>Implementations§
Source§impl RpcNotification
impl RpcNotification
Sourcepub fn from_value(
value: Value,
) -> Result<RpcNotification, RpcRequestParsingError>
pub fn from_value( value: Value, ) -> Result<RpcNotification, RpcRequestParsingError>
Parses a serde_json::Value into an RpcNotification.
This method performs checks according to the JSON-RPC 2.0 specification:
- Checks if the input is a JSON object.
- Validates the presence and value of the
"jsonrpc": "2.0"field. - Validates the presence and type of the
"method"field (must be a string). - Validates the type of the
"params"field (must be array or object if present). - Ensures no
"id"field is present (as it’s a notification).
§Errors
Returns RpcRequestParsingError if any validation fails.
Trait Implementations§
Source§impl Clone for RpcNotification
impl Clone for RpcNotification
Source§fn clone(&self) -> RpcNotification
fn clone(&self) -> RpcNotification
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RpcNotification
impl Debug for RpcNotification
Source§impl<'de> Deserialize<'de> for RpcNotification
impl<'de> Deserialize<'de> for RpcNotification
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
Source§impl From<RpcRequest> for RpcNotification
impl From<RpcRequest> for RpcNotification
Source§fn from(request: RpcRequest) -> Self
fn from(request: RpcRequest) -> Self
Converts to this type from the input type.
Source§impl PartialEq for RpcNotification
impl PartialEq for RpcNotification
Source§impl Serialize for RpcNotification
impl Serialize for RpcNotification
Source§impl TryFrom<Value> for RpcNotification
Convenient TryFrom, performs strict JSON-RPC 2.0 validation via RpcNotification::from_value.
impl TryFrom<Value> for RpcNotification
Convenient TryFrom, performs strict JSON-RPC 2.0 validation via RpcNotification::from_value.
Source§type Error = RpcRequestParsingError
type Error = RpcRequestParsingError
The type returned in the event of a conversion error.
Source§fn try_from(value: Value) -> Result<RpcNotification, RpcRequestParsingError>
fn try_from(value: Value) -> Result<RpcNotification, RpcRequestParsingError>
Performs the conversion.
impl StructuralPartialEq for RpcNotification
Auto Trait Implementations§
impl Freeze for RpcNotification
impl RefUnwindSafe for RpcNotification
impl Send for RpcNotification
impl Sync for RpcNotification
impl Unpin for RpcNotification
impl UnwindSafe for RpcNotification
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