Skip to main content

CardFetchOptions

Struct CardFetchOptions 

Source
pub struct CardFetchOptions { /* private fields */ }
Expand description

What a card fetch sends and how long it may take.

resolve_agent_card and fetch_card_from_url send no headers and allow the whole call 30 seconds. Both were fixed until 0.12, which meant a card behind authentication could not be fetched at all and the budget could not be shortened for a peer that is expected to answer at once. The _with_options variants take one of these instead.

The timeout is one deadline for connect, headers and body together — see the note on the default — not a per-phase bound.

use std::time::Duration;
use a2a_protocol_client::discovery::CardFetchOptions;

let options = CardFetchOptions::default()
    .with_header("authorization", "Bearer s3cret")
    .with_timeout(Duration::from_secs(5));
assert_eq!(options.timeout(), Duration::from_secs(5));
assert_eq!(options.headers().len(), 1);
assert!(!format!("{options:?}").contains("s3cret"));

Its Debug prints header names, never values.

Implementations§

Source§

impl CardFetchOptions

Source

pub fn with_tls_config(self, tls: ClientConfig) -> CardFetchOptions

Available on crate feature tls-rustls only.

Verifies the card’s server against tls instead of the roots default_tls_config trusts: an agent behind a private CA, or one that asks for a client certificate (tls_config_from_pem builds one from PEM). jwks::fetch_jwks (feature signing) honours it too, so the key server a signed card’s keys come from can be private as well.

Until 2026-10-31 the card resolver and the JWK Set fetch had no TLS option at all: only SSL_CERT_FILE reached them, so an agent behind a private CA could be called (ClientBuilder::with_tls_config) but not discovered in code (audit B-03).

Source

pub fn with_header( self, name: impl Into<String>, value: impl Into<String>, ) -> CardFetchOptions

Adds one header to the request. An invalid name or value is reported by the fetch as ClientError::Transport, not here.

Source

pub fn with_signature_keys(self, keys: Jwks) -> CardFetchOptions

Available on crate feature signing only.

Verifies a signed card against keys before returning it (spec §14: clients SHOULD verify signatures when present). A card that carries signatures is returned only if at least one verifies against a key in keys, matched by kid; otherwise the fetch fails with ClientError::Protocol.

An unsigned card fails the fetch too, unless with_require_signature(false) says otherwise: anyone able to alter a card on its way can also remove its signatures, so a fetch that returned an unsigned card would return the altered one unverified.

The keys are the caller’s trust decision: from a trusted store, or from fetch_jwks on a URL the caller trusts. A jku named inside the card is not followed, since the card being checked cannot vouch for its own keys.

Source

pub const fn with_require_signature(self, require: bool) -> CardFetchOptions

Available on crate feature signing only.

Whether a fetch with with_signature_keys refuses a card that carries no signature. Default: true.

false verifies signatures only when present, which is all §14 asks, for a caller whose agents are not all signed: a signed card must still verify, and an unsigned one is returned as it is. It accepts a card whose signatures were removed on the way, too; the caller decides whether an unsigned card is good enough. Without signature keys nothing is verified and this has no effect.

Source

pub fn with_jwks_header( self, name: impl Into<String>, value: impl Into<String>, ) -> CardFetchOptions

Available on crate feature signing only.

Adds one header to a JWK Set fetch (fetch_jwks) and to nothing else.

A key server is another trust domain than the agent: the headers of with_header, an Authorization or a Cookie for the card, are never sent to it. Set here what a key server itself asks for, such as a bearer token for a private key store. An invalid name or value is reported by the fetch as ClientError::Transport, not here.

Until 2026-11-06 fetch_jwks sent the headers of with_header to the key server too (RFC 8725 section 3.10 advises against cookies in a key fetch); a caller that relied on that sets them here.

Source

pub fn with_headers(self, headers: HashMap<String, String>) -> CardFetchOptions

Replaces the headers sent with the request.

Source

pub const fn with_timeout(self, timeout: Duration) -> CardFetchOptions

Sets the budget for the whole fetch: connect, headers and body.

Source

pub const fn headers(&self) -> &HashMap<String, String>

The headers the request will carry.

Source

pub const fn jwks_headers(&self) -> &HashMap<String, String>

Available on crate feature signing only.

The headers a JWK Set fetch will carry besides Accept; see with_jwks_header.

Source

pub const fn timeout(&self) -> Duration

The budget for the whole fetch.

Trait Implementations§

Source§

impl Clone for CardFetchOptions

Source§

fn clone(&self) -> CardFetchOptions

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 CardFetchOptions

Source§

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

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

impl Default for CardFetchOptions

Source§

fn default() -> CardFetchOptions

No headers; the 30-second budget the plain functions use.

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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.

§

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

§

fn from_ref(input: &T) -> T

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

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

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

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

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

impl<L> LayerExt<L> for L

§

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].
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

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

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