pub struct RequestContext {
pub protocol_version: ProtocolVersion,
pub client_capabilities: ClientCapabilities,
pub client_info: Option<Implementation>,
pub progress_token: Option<ProgressToken>,
pub log_level: Option<LoggingLevel>,
}Expand description
Per-request context extracted from RequestMetaObject and carried to every handler.
The 2026-07-28 protocol has no initialize handshake: protocol version, client identity,
capabilities and optional progress/log-level hints are declared in _meta on every request.
Servers MUST NOT infer these values from prior requests.
Fields§
§protocol_version: ProtocolVersionThe negotiated protocol version for this request.
client_capabilities: ClientCapabilitiesThe client’s capabilities (required per spec).
client_info: Option<Implementation>The client’s self-reported identity (SHOULD per spec).
progress_token: Option<ProgressToken>Opaque token for progress notifications, if the caller requests them.
log_level: Option<LoggingLevel>Desired log level for this request (SEP-2577 deprecated; may be absent or ignored).
Implementations§
Source§impl RequestContext
impl RequestContext
Sourcepub fn from_request_meta(meta: &RequestMetaObject) -> Result<Self, RpcError>
pub fn from_request_meta(meta: &RequestMetaObject) -> Result<Self, RpcError>
Builds a validated RequestContext from the wire RequestMetaObject.
Returns UnsupportedProtocolVersionError (-32022) when the protocol
version is unknown to this implementation or is a known version the
server has chosen not to support (see
crate::utils::supported_protocol_versions). The error data carries
the supported versions and echoes the requested version.
Sourcepub fn ensure_capabilities(
&self,
method: &str,
required: &[RequiredClientCapability],
) -> Result<(), RpcError>
pub fn ensure_capabilities( &self, method: &str, required: &[RequiredClientCapability], ) -> Result<(), RpcError>
Enforce that the client declared every required capability.
Returns Ok(()) when all requirements are met, otherwise an error
with code crate::schema::MISSING_REQUIRED_CLIENT_CAPABILITY (-32021) whose
data.requiredCapabilities is a ClientCapabilities-shaped object
keyed by each missing capability (e.g. { "sampling": {} }).
Sourcepub fn client_extensions(&self) -> Option<&BTreeMap<String, JsonObject>>
pub fn client_extensions(&self) -> Option<&BTreeMap<String, JsonObject>>
Returns the client’s declared extensions, if any.