pub struct WebA2AClient {
pub http: HttpClient,
}Expand description
Web-friendly A2A client that wraps both HTTP and WebSocket clients.
This is the main entry point for interacting with A2A agents from web applications. It provides a unified interface for both HTTP and WebSocket transports, with automatic fallback and retry logic.
§Examples
§HTTP-only client
use a2a_client::WebA2AClient;
let client = WebA2AClient::new_http("http://localhost:8080".to_string());§Client configured for streaming
use a2a_client::WebA2AClient;
let client = WebA2AClient::new_http("http://localhost:8080".to_string());§Auto-detecting transports
use a2a_client::WebA2AClient;
let client = WebA2AClient::auto_connect("http://localhost:8080").await?;Fields§
§http: HttpClientHTTP client for A2A requests and streaming
Implementations§
Source§impl WebA2AClient
impl WebA2AClient
Sourcepub fn builder() -> WebA2AClientBuilder
pub fn builder() -> WebA2AClientBuilder
Create a builder for configuring the client.
§Examples
use a2a_client::WebA2AClient;
let client = WebA2AClient::builder()
.http_url("http://localhost:8080")
.build();Sourcepub async fn auto_connect(base_url: &str) -> Result<Self>
pub async fn auto_connect(base_url: &str) -> Result<Self>
Auto-connect to an agent, attempting to detect available transports.
Probes for WebSocket support by fetching the agent card from the server. Falls back to HTTP-only if agent card fetching fails or if WebSocket is not supported.
§Arguments
base_url- Base URL of the A2A agent
§Examples
use a2a_client::WebA2AClient;
let client = WebA2AClient::auto_connect("http://localhost:8080").await?;Auto Trait Implementations§
impl !Freeze for WebA2AClient
impl !RefUnwindSafe for WebA2AClient
impl Send for WebA2AClient
impl Sync for WebA2AClient
impl Unpin for WebA2AClient
impl UnsafeUnpin for WebA2AClient
impl !UnwindSafe for WebA2AClient
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