pub struct JsonRpcNotification {
pub jsonrpc: String,
pub method: String,
pub params: Option<Value>,
}Expand description
JSON-RPC 2.0 notification message.
Represents a one-way message that doesn’t expect a response. Used for events, logging, and other fire-and-forget communications.
Fields§
§jsonrpc: StringJSON-RPC version (always “2.0”)
method: StringMethod name being invoked
params: Option<Value>Parameters for the method (can be object or array)
Implementations§
Source§impl JsonRpcNotification
impl JsonRpcNotification
Sourcepub fn new(method: impl Into<String>, params: Value) -> Self
pub fn new(method: impl Into<String>, params: Value) -> Self
Create a new JSON-RPC notification with the given method and parameters.
§Examples
use mcp_probe_core::messages::core::JsonRpcNotification;
use serde_json::json;
let notification = JsonRpcNotification::new(
"notifications/cancelled",
json!({"requestId": "1"}),
);Sourcepub fn without_params(method: impl Into<String>) -> Self
pub fn without_params(method: impl Into<String>) -> Self
Create a new JSON-RPC notification without parameters.
§Examples
use mcp_probe_core::messages::core::JsonRpcNotification;
let notification = JsonRpcNotification::without_params("ping");Sourcepub fn has_params(&self) -> bool
pub fn has_params(&self) -> bool
Check if this notification has parameters.
Sourcepub fn params_as<T>(&self) -> Result<T, Error>where
T: for<'de> Deserialize<'de>,
pub fn params_as<T>(&self) -> Result<T, Error>where
T: for<'de> Deserialize<'de>,
Get the parameters as a specific type.
Trait Implementations§
Source§impl Clone for JsonRpcNotification
impl Clone for JsonRpcNotification
Source§fn clone(&self) -> JsonRpcNotification
fn clone(&self) -> JsonRpcNotification
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 JsonRpcNotification
impl Debug for JsonRpcNotification
Source§impl<'de> Deserialize<'de> for JsonRpcNotification
impl<'de> Deserialize<'de> for JsonRpcNotification
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<JsonRpcNotification> for JsonRpcMessage
impl From<JsonRpcNotification> for JsonRpcMessage
Source§fn from(notif: JsonRpcNotification) -> Self
fn from(notif: JsonRpcNotification) -> Self
Converts to this type from the input type.
Source§impl PartialEq for JsonRpcNotification
impl PartialEq for JsonRpcNotification
Source§impl Serialize for JsonRpcNotification
impl Serialize for JsonRpcNotification
impl Eq for JsonRpcNotification
impl StructuralPartialEq for JsonRpcNotification
Auto Trait Implementations§
impl Freeze for JsonRpcNotification
impl RefUnwindSafe for JsonRpcNotification
impl Send for JsonRpcNotification
impl Sync for JsonRpcNotification
impl Unpin for JsonRpcNotification
impl UnwindSafe for JsonRpcNotification
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.