pub enum RawJsonRpcId {
Null,
Number(i64),
Str(String),
}Expand description
A JSON-RPC id exactly as it appears on the wire: an integer, a string or
null.
This is the ID of RawJsonRpcMessage and its
requests and responses, whichever ACP version the connection speaks. The
SDK’s request handles return it from raw_id(); their id() returns the
request ID type of their Protocol version. It keeps the wire form: 1
and "1" are different IDs, and integers are kept exactly across the
whole 64-bit signed range, which is the range every ACP schema version
accepts. Other numbers are not valid IDs.
null is allowed because JSON-RPC allows it, and protocol v1 accepts it
on requests. Protocol v2 does not; the SDK rejects a v2 request with a
null ID before dispatch. Error responses to messages whose ID cannot be
read also carry null.
It converts losslessly to and from
v1::schema::RequestId, and from
v2::schema::RequestId. Converting to v2::schema::RequestId fails only
for null:
use agent_client_protocol::{RawJsonRpcId, v1::schema};
let id = RawJsonRpcId::from(schema::RequestId::Number(7));
assert_eq!(id, RawJsonRpcId::Number(7));
assert_eq!(schema::RequestId::from(id), schema::RequestId::Number(7));
assert_eq!(serde_json::to_string(&RawJsonRpcId::from("7".to_string())).unwrap(), r#""7""#);Variants§
Trait Implementations§
Source§impl Clone for RawJsonRpcId
impl Clone for RawJsonRpcId
Source§impl Debug for RawJsonRpcId
impl Debug for RawJsonRpcId
Source§impl<'de> Deserialize<'de> for RawJsonRpcId
impl<'de> Deserialize<'de> for RawJsonRpcId
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 Display for RawJsonRpcId
impl Display for RawJsonRpcId
impl Eq for RawJsonRpcId
Source§impl From<RawJsonRpcId> for RequestId
impl From<RawJsonRpcId> for RequestId
Source§fn from(id: RawJsonRpcId) -> Self
fn from(id: RawJsonRpcId) -> Self
Source§impl From<RequestId> for RawJsonRpcId
impl From<RequestId> for RawJsonRpcId
Source§impl From<RequestId> for RawJsonRpcId
Available on crate feature unstable_protocol_v2 only.
impl From<RequestId> for RawJsonRpcId
unstable_protocol_v2 only.Source§impl From<String> for RawJsonRpcId
impl From<String> for RawJsonRpcId
Source§impl From<i64> for RawJsonRpcId
impl From<i64> for RawJsonRpcId
Source§impl Hash for RawJsonRpcId
impl Hash for RawJsonRpcId
Source§impl JsonSchema for RawJsonRpcId
Available on crate feature schemars only.
impl JsonSchema for RawJsonRpcId
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 moreSource§impl Ord for RawJsonRpcId
impl Ord for RawJsonRpcId
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for RawJsonRpcId
impl PartialEq for RawJsonRpcId
Source§impl PartialOrd for RawJsonRpcId
impl PartialOrd for RawJsonRpcId
Source§impl Serialize for RawJsonRpcId
impl Serialize for RawJsonRpcId
impl StructuralPartialEq for RawJsonRpcId
Source§impl TryFrom<RawJsonRpcId> for RequestId
Available on crate feature unstable_protocol_v2 only.
impl TryFrom<RawJsonRpcId> for RequestId
unstable_protocol_v2 only.Auto Trait Implementations§
impl Freeze for RawJsonRpcId
impl RefUnwindSafe for RawJsonRpcId
impl Send for RawJsonRpcId
impl Sync for RawJsonRpcId
impl Unpin for RawJsonRpcId
impl UnsafeUnpin for RawJsonRpcId
impl UnwindSafe for RawJsonRpcId
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,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
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.