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
impl CardFetchOptions
Sourcepub fn with_tls_config(self, tls: ClientConfig) -> CardFetchOptions
Available on crate feature tls-rustls only.
pub fn with_tls_config(self, tls: ClientConfig) -> CardFetchOptions
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).
Sourcepub fn with_header(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> CardFetchOptions
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.
Sourcepub fn with_signature_keys(self, keys: Jwks) -> CardFetchOptions
Available on crate feature signing only.
pub fn with_signature_keys(self, keys: Jwks) -> CardFetchOptions
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.
Sourcepub const fn with_require_signature(self, require: bool) -> CardFetchOptions
Available on crate feature signing only.
pub const fn with_require_signature(self, require: bool) -> CardFetchOptions
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.
Sourcepub fn with_jwks_header(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> CardFetchOptions
Available on crate feature signing only.
pub fn with_jwks_header( self, name: impl Into<String>, value: impl Into<String>, ) -> CardFetchOptions
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.
Sourcepub fn with_headers(self, headers: HashMap<String, String>) -> CardFetchOptions
pub fn with_headers(self, headers: HashMap<String, String>) -> CardFetchOptions
Replaces the headers sent with the request.
Sourcepub const fn with_timeout(self, timeout: Duration) -> CardFetchOptions
pub const fn with_timeout(self, timeout: Duration) -> CardFetchOptions
Sets the budget for the whole fetch: connect, headers and body.
Sourcepub const fn jwks_headers(&self) -> &HashMap<String, String>
Available on crate feature signing only.
pub const fn jwks_headers(&self) -> &HashMap<String, String>
signing only.The headers a JWK Set fetch will carry besides Accept; see
with_jwks_header.
Trait Implementations§
Source§impl Clone for CardFetchOptions
impl Clone for CardFetchOptions
Source§fn clone(&self) -> CardFetchOptions
fn clone(&self) -> CardFetchOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CardFetchOptions
impl Debug for CardFetchOptions
Source§impl Default for CardFetchOptions
impl Default for CardFetchOptions
Source§fn default() -> CardFetchOptions
fn default() -> CardFetchOptions
No headers; the 30-second budget the plain functions use.
Auto Trait Implementations§
impl !RefUnwindSafe for CardFetchOptions
impl !UnwindSafe for CardFetchOptions
impl Forget for CardFetchOptions
impl Freeze for CardFetchOptions
impl Move for CardFetchOptions
impl Send for CardFetchOptions
impl Sync for CardFetchOptions
impl Unpin for CardFetchOptions
impl UnsafeUnpin for CardFetchOptions
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].