pub struct JsonRpcRequest {
pub jsonrpc: Cow<'static, str>,
pub method: String,
pub params: Option<Value>,
pub id: Option<RequestId>,
}Expand description
JSON-RPC 2.0 request.
Fields§
§jsonrpc: Cow<'static, str>Protocol version (always “2.0”).
method: StringMethod name.
params: Option<Value>Request parameters.
id: Option<RequestId>Request ID (absent for notifications).
An explicit JSON null is rejected instead of being conflated with an
absent member. Notifications omit id entirely.
Implementations§
Source§impl JsonRpcRequest
impl JsonRpcRequest
Sourcepub fn decode_strict_with_raw_params(
bytes: &[u8],
document_byte_limit: usize,
) -> Result<(Self, Option<String>), JsonRpcAdmissionError>
pub fn decode_strict_with_raw_params( bytes: &[u8], document_byte_limit: usize, ) -> Result<(Self, Option<String>), JsonRpcAdmissionError>
Strictly decodes one request while retaining an exact parameter-source sidecar for method-specific ingress decoding.
The returned String, when present, is the exact JSON source of the
request’s params member. It is deliberately separate from
JsonRpcRequest so existing public struct literals and ordinary
typed request APIs retain their established shape. A consumer may only
attach this source to the returned request after comparing its
materialized params value; final core dispatch performs that equality
check before it uses the raw source.
This applies the same bounded raw-document admission as
decode_strict_jsonrpc_message, including duplicate-member
rejection, before producing either the typed request or its sidecar.
Source§impl JsonRpcRequest
impl JsonRpcRequest
Sourcepub fn new(
method: impl Into<String>,
params: Option<Value>,
id: impl Into<RequestId>,
) -> Self
pub fn new( method: impl Into<String>, params: Option<Value>, id: impl Into<RequestId>, ) -> Self
Creates a new request with the given method and parameters.
Sourcepub fn notification(method: impl Into<String>, params: Option<Value>) -> Self
pub fn notification(method: impl Into<String>, params: Option<Value>) -> Self
Creates a notification (request without ID).
Sourcepub fn initialized_notification() -> Self
pub fn initialized_notification() -> Self
Creates the MCP lifecycle notifications/initialized notification.
Uses the spec-correct method name (notifications/initialized), avoiding
the bare initialized spelling that compliant servers do not route as the
lifecycle ack.
Sourcepub fn is_notification(&self) -> bool
pub fn is_notification(&self) -> bool
Returns true if this is a notification (no ID).
Trait Implementations§
Source§impl Clone for JsonRpcRequest
impl Clone for JsonRpcRequest
Source§fn clone(&self) -> JsonRpcRequest
fn clone(&self) -> JsonRpcRequest
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more