pub struct Client { /* private fields */ }Expand description
A2A protocol client.
Wraps a Transport and applies CallInterceptors before/after each call.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(transport: Box<dyn Transport>) -> Client
pub fn new(transport: Box<dyn Transport>) -> Client
Creates a new client wrapping the given transport.
Sourcepub fn from_url(base_url: impl Into<String>) -> Result<Client, A2AError>
pub fn from_url(base_url: impl Into<String>) -> Result<Client, A2AError>
Creates a client from a base URL using JsonRpcTransport.
Sourcepub fn with_config(self, config: ClientConfig) -> Client
pub fn with_config(self, config: ClientConfig) -> Client
Sets client configuration.
Sourcepub fn with_interceptor(
self,
interceptor: impl CallInterceptor + 'static,
) -> Client
pub fn with_interceptor( self, interceptor: impl CallInterceptor + 'static, ) -> Client
Adds a call interceptor.
Sourcepub fn with_interceptor_arc(
self,
interceptor: Arc<dyn CallInterceptor>,
) -> Client
pub fn with_interceptor_arc( self, interceptor: Arc<dyn CallInterceptor>, ) -> Client
Adds a pre-built call interceptor from an Arc.
Sourcepub async fn send_message(
&self,
req: &SendMessageRequest,
) -> Result<SendMessageResponse, A2AError>
pub async fn send_message( &self, req: &SendMessageRequest, ) -> Result<SendMessageResponse, A2AError>
Sends a message (non-streaming).
Sourcepub async fn send_streaming_message(
&self,
req: &SendMessageRequest,
) -> Result<Pin<Box<dyn Stream<Item = Result<StreamResponse, A2AError>> + Send>>, A2AError>
pub async fn send_streaming_message( &self, req: &SendMessageRequest, ) -> Result<Pin<Box<dyn Stream<Item = Result<StreamResponse, A2AError>> + Send>>, A2AError>
Sends a message with streaming response.
Sourcepub async fn list_tasks(
&self,
req: &ListTasksRequest,
) -> Result<ListTasksResponse, A2AError>
pub async fn list_tasks( &self, req: &ListTasksRequest, ) -> Result<ListTasksResponse, A2AError>
Lists tasks.
Sourcepub async fn cancel_task(
&self,
req: &CancelTaskRequest,
) -> Result<Task, A2AError>
pub async fn cancel_task( &self, req: &CancelTaskRequest, ) -> Result<Task, A2AError>
Cancels a task.
Sourcepub async fn subscribe_to_task(
&self,
req: &SubscribeToTaskRequest,
) -> Result<Pin<Box<dyn Stream<Item = Result<StreamResponse, A2AError>> + Send>>, A2AError>
pub async fn subscribe_to_task( &self, req: &SubscribeToTaskRequest, ) -> Result<Pin<Box<dyn Stream<Item = Result<StreamResponse, A2AError>> + Send>>, A2AError>
Subscribes to task updates.
Sourcepub async fn get_agent_card(&self) -> Result<AgentCard, A2AError>
pub async fn get_agent_card(&self) -> Result<AgentCard, A2AError>
Retrieves the public agent card.
Returns the cached version if available and the agent doesn’t support extended cards.
Auto Trait Implementations§
impl !Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
impl !UnwindSafe for Client
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