Skip to main content

ClientConfig

Struct ClientConfig 

Source
#[non_exhaustive]
pub struct ClientConfig { pub preferred_bindings: Vec<String>, pub accepted_output_modes: Vec<String>, pub history_length: Option<u32>, pub return_immediately: bool, pub request_timeout: Duration, pub stream_connect_timeout: Duration, pub connection_timeout: Duration, pub max_response_size: usize, pub tls: TlsConfig, pub tenant: Option<String>, }
Expand description

Configuration for an crate::A2aClient instance.

Build via crate::ClientBuilder. Reasonable defaults are provided for all fields; most users only need to set the agent URL.

#[non_exhaustive]: build it with Default and the with_* setters, which cover every field; a struct literal is not available outside this crate, so a field added later does not break callers.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§preferred_bindings: Vec<String>

Ordered list of preferred protocol bindings.

The client tries each in order, selecting the first one supported by the target agent’s card. Defaults to ["JSONRPC"].

§accepted_output_modes: Vec<String>

MIME types the client will advertise in acceptedOutputModes.

Defaults to ["text/plain", "application/json"].

§history_length: Option<u32>

Number of historical messages to include in task responses.

None means use the agent’s default.

§return_immediately: bool

If true, send_message returns immediately with the submitted task rather than waiting for completion.

§request_timeout: Duration

Per-request timeout for non-streaming calls.

Defaults to 30 seconds.

§stream_connect_timeout: Duration

Per-request timeout for establishing the SSE stream.

Once the stream is established this timeout no longer applies. Defaults to 30 seconds.

§connection_timeout: Duration

TCP connection timeout (DNS + handshake).

Prevents the client from hanging for the OS default (~2 minutes) when the server is unreachable. Defaults to 10 seconds.

§max_response_size: usize

Maximum size in bytes of a buffered (non-streaming) response body.

Responses exceeding this cap fail with a transport error instead of being buffered without bound. Defaults to 32 MiB — large enough for big task histories and inline artifacts while still bounding client memory against a hostile or buggy server.

§What it reaches

Every transport ClientBuilder constructs: JSON-RPC and REST enforce it directly, and gRPC and WebSocket receive it as their max_message_size.

It does not reach a transport supplied by with_custom_transport, which never sees this config and carries whatever bound it was built with. Two shipped transports are in that position:

  • WebSocketTransport — bounded by WebSocketTransportConfig::max_message_size, which defaults to this same constant. So the two agree until you change one: tightening max_response_size to 1 MiB and connecting over WebSocket still admits 32 MiB. Set it on WebSocketTransportConfig instead.
  • SlimRpcTransport in a2a-protocol-slimrpc — receive cap is tonic’s inherited 4 MiB, eight times tighter than this default, and not settable at all.
§tls: TlsConfig

TLS configuration.

§tenant: Option<String>

Default tenant identifier for multi-tenancy.

When set, this tenant is included in all requests unless overridden per-request. Automatically populated from AgentInterface.tenant when building via crate::ClientBuilder::from_card.

Implementations§

Source§

impl ClientConfig

Source

pub fn default_http() -> Self

Returns the default configuration suitable for connecting to a local or well-known agent over plain HTTP.

Source§

impl ClientConfig

Source

pub fn with_preferred_bindings(self, bindings: Vec<String>) -> Self

Sets the ordered binding preference list.

Source

pub fn with_accepted_output_modes(self, modes: Vec<String>) -> Self

Sets the MIME types advertised in acceptedOutputModes.

Source

pub const fn with_history_length(self, length: Option<u32>) -> Self

Sets the history length requested; None uses the agent’s default.

Source

pub const fn with_return_immediately(self, val: bool) -> Self

Sets whether send_message returns as soon as the task is submitted.

Source

pub const fn with_request_timeout(self, timeout: Duration) -> Self

Sets the per-request timeout for non-streaming calls.

Source

pub const fn with_stream_connect_timeout(self, timeout: Duration) -> Self

Sets the timeout for establishing the SSE stream.

Source

pub const fn with_connection_timeout(self, timeout: Duration) -> Self

Sets the TCP connection timeout (DNS + handshake).

Source

pub const fn with_max_response_size(self, max_bytes: usize) -> Self

Sets the buffered response body cap. See max_response_size for which transports it reaches.

Source

pub const fn with_tls(self, tls: TlsConfig) -> Self

Sets the TLS configuration.

Source

pub fn with_tenant(self, tenant: Option<String>) -> Self

Sets the default tenant; None sends none unless a request names one.

Trait Implementations§

Source§

impl Clone for ClientConfig

Source§

fn clone(&self) -> ClientConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ClientConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ClientConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more