pub enum JsonRpcRequestId {
Absent,
Null,
Value(Value),
}Expand description
A JSON-RPC 2.0 request identifier with three distinct states.
JSON-RPC 2.0 distinguishes an absent id member (the request is a
notification — no response is expected) from an explicit null id
(a call — discouraged by the spec, but a call nonetheless, answered with a
null-id response). Modeling the id as Option<Value> collapses these two
states, so an explicit "id": null would round-trip into a notification.
Variants§
Absent
The id member was absent: the request is a notification.
Null
The id member was an explicit null: a call with a null id.
Value(Value)
A string or number id. (Kept permissive as a raw JSON value, matching the previous behavior of accepting any JSON type here.)
Implementations§
Source§impl JsonRpcRequestId
impl JsonRpcRequestId
Sourcepub const fn is_absent(&self) -> bool
pub const fn is_absent(&self) -> bool
Returns true when the id member is absent (a notification).
Sourcepub const fn as_value(&self) -> Option<&Value>
pub const fn as_value(&self) -> Option<&Value>
Returns the id value, if this is a Self::Value.
Sourcepub fn to_response_id(&self) -> Option<Value>
pub fn to_response_id(&self) -> Option<Value>
Converts to the id a response to this request must carry:
the request value, or null for a null-id call.
A notification (Self::Absent) expects no response at all; callers
that respond anyway (as this SDK’s HTTP dispatch does, treating every
A2A request as a call) get null, mirroring the spec’s rule for
requests whose id could not be determined.
Trait Implementations§
Source§impl Clone for JsonRpcRequestId
impl Clone for JsonRpcRequestId
Source§fn clone(&self) -> JsonRpcRequestId
fn clone(&self) -> JsonRpcRequestId
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for JsonRpcRequestId
impl Debug for JsonRpcRequestId
Source§impl Default for JsonRpcRequestId
impl Default for JsonRpcRequestId
Source§fn default() -> JsonRpcRequestId
fn default() -> JsonRpcRequestId
Source§impl<'de> Deserialize<'de> for JsonRpcRequestId
impl<'de> Deserialize<'de> for JsonRpcRequestId
Source§fn deserialize<D>(
deserializer: D,
) -> Result<JsonRpcRequestId, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<JsonRpcRequestId, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
impl Eq for JsonRpcRequestId
Source§impl From<Value> for JsonRpcRequestId
impl From<Value> for JsonRpcRequestId
Source§fn from(value: Value) -> JsonRpcRequestId
fn from(value: Value) -> JsonRpcRequestId
Source§impl PartialEq for JsonRpcRequestId
impl PartialEq for JsonRpcRequestId
Source§impl Serialize for JsonRpcRequestId
impl Serialize for JsonRpcRequestId
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl StructuralPartialEq for JsonRpcRequestId
Auto Trait Implementations§
impl Freeze for JsonRpcRequestId
impl RefUnwindSafe for JsonRpcRequestId
impl Send for JsonRpcRequestId
impl Sync for JsonRpcRequestId
impl Unpin for JsonRpcRequestId
impl UnsafeUnpin for JsonRpcRequestId
impl UnwindSafe for JsonRpcRequestId
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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
key and return true if they are equal.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request