pub struct CardClient { /* private fields */ }Expand description
Fetches and checks the cards other agents publish.
Implementations§
Source§impl CardClient
impl CardClient
Sourcepub const DEFAULT_TIMEOUT: Duration
pub const DEFAULT_TIMEOUT: Duration
How long a card fetch may take in total.
Ten seconds: a card is a small static document, and a server that cannot produce one in that time is not one worth waiting on. Unbounded is the wrong default anywhere, and here it lets an unknown host hold a task open for as long as it likes.
pub fn new() -> Self
Sourcepub const fn allow_loopback(self) -> Self
pub const fn allow_loopback(self) -> Self
Permit a card served from this machine.
Behind testkit and therefore absent from a production build, which
is the property that matters: an exception that can only be compiled
into a test binary cannot be left on by accident in a deployment.
It applies to a host that is a loopback literal or localhost — never
to one that merely resolved to one, which is the rebinding attack and
stays refused with the flag set. See
netguard::is_loopback_name.
Sourcepub const fn timeout(self, timeout: Duration) -> Self
pub const fn timeout(self, timeout: Duration) -> Self
Change the whole-request timeout.
§Panics
If zero, which would spell never fetch a card as if it were a policy.
Sourcepub fn verifying_with(self, verifier: Arc<dyn CardVerifier>) -> Self
pub fn verifying_with(self, verifier: Arc<dyn CardVerifier>) -> Self
Require a signature from a key this verifier trusts.
Off by default, and that is a deliberate choice rather than an oversight: most cards in the wild are unsigned today, and a client that refused them all would simply not be used. Setting this makes verification mandatory — an unsigned card is then refused, because a verifier that accepts an unsigned card whenever one arrives is one an attacker downgrades by stripping the signature.
Sourcepub async fn discover(&self, origin: &str) -> Result<AgentCard, DiscoveryError>
pub async fn discover(&self, origin: &str) -> Result<AgentCard, DiscoveryError>
Fetch the card an agent publishes at its well-known path.
origin is a scheme and host — the path is the spec’s, not the caller’s,
which is the point of a well-known location.
§Errors
DiscoveryError::Refused when egress forbids the host,
DiscoveryError::Unreachable on a transport failure,
DiscoveryError::Malformed when the body is not a card, and
DiscoveryError::Signature when verification is required and fails.
Trait Implementations§
Source§impl Clone for CardClient
impl Clone for CardClient
Source§impl Debug for CardClient
impl Debug for CardClient
Auto Trait Implementations§
impl !Freeze for CardClient
impl !RefUnwindSafe for CardClient
impl !UnwindSafe for CardClient
impl Send for CardClient
impl Sync for CardClient
impl Unpin for CardClient
impl UnsafeUnpin for CardClient
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
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,
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> 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