#[non_exhaustive]pub enum ProtocolLevelNotification {
CancelRequestNotification(CancelRequestNotification),
}unstable_protocol_v2 only.Expand description
General protocol-level notifications that all sides are expected to implement.
Notifications whose methods start with ‘$/’ are messages which
are protocol implementation dependent and might not be implementable in all
clients or agents. For example if the implementation uses a single threaded
synchronous programming language then there is little it can do to react to
a $/cancel_request notification. If an agent or client receives
notifications starting with ‘$/’ it is free to ignore the notification.
Notifications do not expect a response.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
CancelRequestNotification(CancelRequestNotification)
Cancels an ongoing request.
This is a notification sent by the side that sent a request to cancel that request.
Upon receiving this notification, the receiver:
- MAY cancel the corresponding request activity and all nested activities
- MAY send any pending notifications.
- MUST still send a response for the original request. If the request already finished
or is not cancelled, that is its normal response. If it is cancelled, it is either the
method’s defined cancellation result (for example an inserted
session/prompt, or acancelledpermission outcome) or an error with code-32800(Request Cancelled).
Receivers MUST ignore this notification for an unknown or already-answered request ID, and MUST NOT send a second response for it.
See protocol docs: Cancellation
Implementations§
Source§impl ProtocolLevelNotification
impl ProtocolLevelNotification
Sourcepub fn supports_method(method: &str) -> bool
pub fn supports_method(method: &str) -> bool
Whether this enum recognizes the method with the enabled Cargo features, including extensions when it has an extension variant.
This does not check the peer’s advertised capabilities.
Sourcepub fn from_method_and_params(
method: &str,
params: &Value,
) -> Result<Self, MethodDispatchError>
pub fn from_method_and_params( method: &str, params: &Value, ) -> Result<Self, MethodDispatchError>
Parses parameters selected by the JSON-RPC method name.
Use this instead of the enum’s untagged Deserialize
implementation. Untagged deserialization selects by payload
shape, which can silently select an unrelated variant.
The payload is passed unchanged to the selected type’s
deserializer. In particular, null is not converted to {}.
Extension payloads retain their JSON value and method name.
§Errors
Returns crate::MethodDispatchError::UnknownMethod for an
unsupported method, or crate::MethodDispatchError::InvalidPayload
for a malformed payload.
Trait Implementations§
Source§impl Clone for ProtocolLevelNotification
impl Clone for ProtocolLevelNotification
Source§impl Debug for ProtocolLevelNotification
impl Debug for ProtocolLevelNotification
Source§impl<'de> Deserialize<'de> for ProtocolLevelNotification
impl<'de> Deserialize<'de> for ProtocolLevelNotification
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>,
Source§impl JsonSchema for ProtocolLevelNotification
Available on crate feature schemars only.
impl JsonSchema for ProtocolLevelNotification
schemars only.Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more