pub struct JsonRpcRequest<P> {
pub jsonrpc: String,
pub id: Value,
pub method: String,
pub params: P,
}Expand description
A JSON-RPC 2.0 request envelope carrying typed parameters P.
The id is always a UUID v4 string, generated in JsonRpcRequest::new.
§Examples
use zeph_a2a::jsonrpc::{JsonRpcRequest, METHOD_GET_TASK, TaskIdParams};
let req = JsonRpcRequest::new(METHOD_GET_TASK, TaskIdParams {
id: "task-123".into(),
history_length: Some(10),
});
assert_eq!(req.method, "tasks/get");
assert_eq!(req.jsonrpc, "2.0");Fields§
§jsonrpc: StringAlways "2.0".
id: ValueUnique request identifier echoed back in the response.
method: StringThe A2A method being invoked (one of the METHOD_* constants).
params: PMethod-specific parameters.
Implementations§
Source§impl<P: Serialize> JsonRpcRequest<P>
impl<P: Serialize> JsonRpcRequest<P>
Sourcepub fn new(method: &str, params: P) -> Self
pub fn new(method: &str, params: P) -> Self
Create a new JSON-RPC 2.0 request with a fresh UUID id.
§Examples
use zeph_a2a::jsonrpc::{JsonRpcRequest, METHOD_CANCEL_TASK, TaskIdParams};
let req = JsonRpcRequest::new(METHOD_CANCEL_TASK, TaskIdParams {
id: "task-abc".into(),
history_length: None,
});
assert_eq!(req.method, "tasks/cancel");Trait Implementations§
Source§impl<P: Clone> Clone for JsonRpcRequest<P>
impl<P: Clone> Clone for JsonRpcRequest<P>
Source§fn clone(&self) -> JsonRpcRequest<P>
fn clone(&self) -> JsonRpcRequest<P>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<P: Debug> Debug for JsonRpcRequest<P>
impl<P: Debug> Debug for JsonRpcRequest<P>
Source§impl<'de, P> Deserialize<'de> for JsonRpcRequest<P>where
P: Deserialize<'de>,
impl<'de, P> Deserialize<'de> for JsonRpcRequest<P>where
P: Deserialize<'de>,
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl<P> Freeze for JsonRpcRequest<P>where
P: Freeze,
impl<P> RefUnwindSafe for JsonRpcRequest<P>where
P: RefUnwindSafe,
impl<P> Send for JsonRpcRequest<P>where
P: Send,
impl<P> Sync for JsonRpcRequest<P>where
P: Sync,
impl<P> Unpin for JsonRpcRequest<P>where
P: Unpin,
impl<P> UnsafeUnpin for JsonRpcRequest<P>where
P: UnsafeUnpin,
impl<P> UnwindSafe for JsonRpcRequest<P>where
P: UnwindSafe,
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
Mutably borrows from an owned value. Read more