pub struct A2AClientFactory { /* private fields */ }Expand description
Factory for creating A2AClient instances with automatic protocol negotiation.
Maintains a registry of TransportFactory implementations indexed by protocol
and major version. When creating a client from an AgentCard, it selects the
best matching transport based on the agent’s declared interfaces and the client’s
preferred bindings.
Implementations§
Source§impl A2AClientFactory
impl A2AClientFactory
Sourcepub fn builder() -> A2AClientFactoryBuilder
pub fn builder() -> A2AClientFactoryBuilder
Create a builder for configuring the factory.
Sourcepub async fn create_from_card(
&self,
card: &AgentCard,
) -> Result<A2AClient<Box<dyn Transport>>, A2AError>
pub async fn create_from_card( &self, card: &AgentCard, ) -> Result<A2AClient<Box<dyn Transport>>, A2AError>
Create a client by negotiating the best transport with the agent card.
Selection algorithm (mirrors Go SDK):
- For each interface in the agent card’s
supported_interfaces - Look up matching factory by (protocol, major_version)
- Rank candidates: client preference order, then newest version
- Try connecting in rank order; first success wins
Sourcepub async fn create_from_card_with_interface(
&self,
card: &AgentCard,
) -> Result<(A2AClient<Box<dyn Transport>>, AgentInterface), A2AError>
pub async fn create_from_card_with_interface( &self, card: &AgentCard, ) -> Result<(A2AClient<Box<dyn Transport>>, AgentInterface), A2AError>
Same negotiation as Self::create_from_card, but also returns the
AgentInterface that was selected — needed by a caller that must
honor that interface’s own declared routing tenant (A2A §8.3.2) on
every subsequent request, which the interface list alone doesn’t
otherwise surface once a client has been built.
Auto Trait Implementations§
impl !RefUnwindSafe for A2AClientFactory
impl !UnwindSafe for A2AClientFactory
impl Freeze for A2AClientFactory
impl Send for A2AClientFactory
impl Sync for A2AClientFactory
impl Unpin for A2AClientFactory
impl UnsafeUnpin for A2AClientFactory
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> 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> 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