pub struct A2aServer { /* private fields */ }Expand description
The A2A server: an Application serving the Agent Card and the
JSON-RPC endpoint.
Implementations§
Source§impl A2aServer
impl A2aServer
Sourcepub fn new(card: AgentCard) -> A2aServer
pub fn new(card: AgentCard) -> A2aServer
An agent described by card; until on_message
it rejects every message.
Sourcepub fn on_message<F>(self, handler: F) -> A2aServer
pub fn on_message<F>(self, handler: F) -> A2aServer
Answer each message.
Sourcepub fn require_bearer(self, token: &str) -> A2aServer
pub fn require_bearer(self, token: &str) -> A2aServer
Require Authorization: Bearer <token> on the JSON-RPC endpoint (the
card stays public and lists the scheme).
Sourcepub fn require_bearer_tokens<'a>(
self,
tokens: impl IntoIterator<Item = (&'a str, &'a str)>,
) -> A2aServer
pub fn require_bearer_tokens<'a>( self, tokens: impl IntoIterator<Item = (&'a str, &'a str)>, ) -> A2aServer
Several tokens, each standing for an identity; callers only see their own tasks.
Sourcepub fn blocking_timeout(self, timeout: Duration) -> A2aServer
pub fn blocking_timeout(self, timeout: Duration) -> A2aServer
How long SendMessage waits for a running task to finish or ask for
input before answering with its current state (default 300 s).
Sourcepub fn push_notifications<'a>(
self,
prefixes: impl IntoIterator<Item = &'a str>,
) -> A2aServer
pub fn push_notifications<'a>( self, prefixes: impl IntoIterator<Item = &'a str>, ) -> A2aServer
Turn push notifications on: clients may register webhooks whose URL
starts with one of prefixes (https://hooks.example.com/). They
come from clients, so only listed destinations are called (SSRF).
Sourcepub fn extended_card(self, card: AgentCard) -> A2aServer
pub fn extended_card(self, card: AgentCard) -> A2aServer
A fuller card for authenticated callers (GetExtendedAgentCard):
skills you don’t advertise publicly, say. Needs bearer tokens.
Trait Implementations§
Source§impl Application for A2aServer
impl Application for A2aServer
Source§fn execute(
&self,
request: &Request,
connection: &ConnectionInfo,
) -> Result<Response, String>
fn execute( &self, request: &Request, connection: &ConnectionInfo, ) -> Result<Response, String>
is_matching / process and return the first match.Source§fn runs_inline(&self, _request: &Request, _connection: &ConnectionInfo) -> bool
fn runs_inline(&self, _request: &Request, _connection: &ConnectionInfo) -> bool
true when executing request is quick and never waits on anything
but the local filesystem — health checks, metrics, small static files.
The async servers (HTTP/1.1, HTTP/2, HTTP/3) then call execute
directly on the event loop, as nginx does, instead of handing the
request to tokio’s blocking pool: that handoff (a shared lock and two
cross-thread wake-ups) costs more than serving a small file. Read moreSource§fn execute_async<'a>(
&'a self,
_request: &'a Request,
_connection: &'a ConnectionInfo,
) -> Option<Pin<Box<dyn Future<Output = Result<Response, String>> + Send + 'a>>>
fn execute_async<'a>( &'a self, _request: &'a Request, _connection: &'a ConnectionInfo, ) -> Option<Pin<Box<dyn Future<Output = Result<Response, String>> + Send + 'a>>>
http2 only.execute for this request, when the
application has one: the async servers await it on the connection’s
task instead of tying up a blocking-pool thread while it waits (the
config-driven proxy uses this to wait for a backend without holding a
thread). None (the default) means “use execute”. Wrappers return
Some only when they add no synchronous work of their own.Source§fn streams_body(&self, _request: &Request, _connection: &ConnectionInfo) -> bool
fn streams_body(&self, _request: &Request, _connection: &ConnectionInfo) -> bool
true to receive this request’s body as a stream (Body::Stream)
instead of read into memory first: execute then runs while the
body is still arriving, on a blocking-pool thread, and reads it with
std::io::Read — a multi-gigabyte upload in a few chunks of memory.
Asked after the head is read, so request.body is empty here;
decide from the method, path and headers. Read moreSource§fn registered_routes(&self) -> Vec<RouteInfo>
fn registered_routes(&self) -> Vec<RouteInfo>
(method, pattern) —
what AppWithState::route_entries returns; wrappers
(WithMiddleware, McpServer) report the routes of the
application inside. For tools that describe an app (the dev MCP
server’s routes tool), not for dispatch. Default: none. Since
18.28.0.Source§fn middleware_names(&self) -> Vec<&'static str>
fn middleware_names(&self) -> Vec<&'static str>
Middleware::layer_name).
Default: none; WithMiddleware lists its layers, then the inner
application’s. Since 18.28.0.Auto Trait Implementations§
impl !RefUnwindSafe for A2aServer
impl !UnwindSafe for A2aServer
impl Freeze for A2aServer
impl Send for A2aServer
impl Sync for A2aServer
impl Unpin for A2aServer
impl UnsafeUnpin for A2aServer
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
map-response-body only.Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
trace only.Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
trace only.