#[non_exhaustive]pub struct AgentInterface {
pub url: String,
pub protocol_binding: String,
pub tenant: Option<String>,
pub protocol_version: String,
}Expand description
Declares a combination of a target URL, transport and protocol version for interacting with the agent. This allows agents to expose the same functionality over multiple protocol binding mechanisms.
AgentInterface::jsonrpc, AgentInterface::grpc and
AgentInterface::rest take a URL and fill in the binding name and the
protocol version; AgentInterface::new takes an arbitrary binding.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.url: StringThe URL where this interface is available. Must be a valid absolute HTTPS URL in production.
Example: "https://api.example.com/a2a/v1", "https://grpc.example.com/a2a"
protocol_binding: StringThe protocol binding supported at this URL. This is an open form string, to be
easily extended for other protocol bindings. The core ones officially
supported are JSONRPC, GRPC and HTTP+JSON.
§12 permits custom bindings, and §5.8 says a custom binding SHOULD be
identified by a URI rather than a bare name, so that two projects cannot
define incompatible bindings under the same word. This crate’s own WebSocket
binding is WEBSOCKET_BINDING_URI; it
advertised the bare "WEBSOCKET" before 0.11.0, which readers should still
accept.
tenant: Option<String>Optional. An opaque string used for routing requests to a specific agent
or tenant when multiple agents are served behind a single A2A endpoint.
When set, clients MUST include this value in the tenant field of all
request messages sent to this interface. The server is responsible for
interpreting the value and routing requests accordingly; the protocol
does not define its format or semantics.
protocol_version: StringThe version of the A2A protocol this interface exposes. Use the latest supported minor version per major version. Examples: “0.3”, “1.0”
Spec §3.6: patch version numbers SHOULD NOT be used in agent cards.
Implementations§
Source§impl AgentInterface
impl AgentInterface
Sourcepub fn new(
url: impl Into<String>,
protocol_binding: impl Into<String>,
) -> AgentInterface
pub fn new( url: impl Into<String>, protocol_binding: impl Into<String>, ) -> AgentInterface
A new interface at url speaking protocol_binding, at this crate’s
A2A_VERSION.
The spec’s canonical bindings are "JSONRPC", "GRPC" and
"HTTP+JSON" (§5.3). Custom bindings are permitted (§12), and §5.8
says one SHOULD be identified by a URI — see
WEBSOCKET_BINDING_URI for this
crate’s own. Prefer Self::jsonrpc, Self::grpc or
Self::rest over spelling a canonical one out.
use a2a_protocol_types::agent_card::AgentInterface;
let iface = AgentInterface::new("https://agent.example.com/rpc", "JSONRPC");
assert_eq!(iface.protocol_version, a2a_protocol_types::A2A_VERSION);
assert!(iface.tenant.is_none());Sourcepub fn jsonrpc(url: impl Into<String>) -> AgentInterface
pub fn jsonrpc(url: impl Into<String>) -> AgentInterface
A JSONRPC interface at url (spec §9).
use a2a_protocol_types::agent_card::AgentInterface;
assert_eq!(
AgentInterface::jsonrpc("https://agent.example.com/rpc").protocol_binding,
"JSONRPC",
);Sourcepub fn grpc(url: impl Into<String>) -> AgentInterface
pub fn grpc(url: impl Into<String>) -> AgentInterface
A GRPC interface at url (spec §10).
use a2a_protocol_types::agent_card::AgentInterface;
assert_eq!(
AgentInterface::grpc("https://agent.example.com").protocol_binding,
"GRPC",
);Sourcepub fn rest(url: impl Into<String>) -> AgentInterface
pub fn rest(url: impl Into<String>) -> AgentInterface
An HTTP+JSON (REST) interface at url (spec §11).
Named for the binding a caller selects, not for the spec’s spelling of
it: HTTP+JSON is easy to mistype and a typo here is a card that
advertises a binding nothing implements.
use a2a_protocol_types::agent_card::AgentInterface;
assert_eq!(
AgentInterface::rest("https://agent.example.com").protocol_binding,
"HTTP+JSON",
);Sourcepub fn with_tenant(self, tenant: impl Into<String>) -> AgentInterface
pub fn with_tenant(self, tenant: impl Into<String>) -> AgentInterface
Scopes this interface to a tenant.
use a2a_protocol_types::agent_card::AgentInterface;
let iface = AgentInterface::jsonrpc("https://a.example.com/rpc").with_tenant("acme");
assert_eq!(iface.tenant.as_deref(), Some("acme"));Source§impl AgentInterface
impl AgentInterface
Sourcepub fn with_protocol_version(self, version: impl Into<String>) -> AgentInterface
pub fn with_protocol_version(self, version: impl Into<String>) -> AgentInterface
Sets the protocol version the interface speaks, where
AgentInterface::new writes the version this crate implements.
Trait Implementations§
Source§impl Clone for AgentInterface
impl Clone for AgentInterface
Source§fn clone(&self) -> AgentInterface
fn clone(&self) -> AgentInterface
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 AgentInterface
impl Debug for AgentInterface
Source§impl<'de> Deserialize<'de> for AgentInterface
impl<'de> Deserialize<'de> for AgentInterface
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<AgentInterface, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<AgentInterface, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<AgentInterface> for AgentInterface
impl From<AgentInterface> for AgentInterface
Source§fn from(value: AgentInterface) -> AgentInterface
fn from(value: AgentInterface) -> AgentInterface
Source§impl Serialize for AgentInterface
impl Serialize for AgentInterface
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Source§impl TryFrom<AgentInterface> for AgentInterface
impl TryFrom<AgentInterface> for AgentInterface
Source§type Error = ConvertError
type Error = ConvertError
Source§fn try_from(
value: AgentInterface,
) -> Result<AgentInterface, <AgentInterface as TryFrom<AgentInterface>>::Error>
fn try_from( value: AgentInterface, ) -> Result<AgentInterface, <AgentInterface as TryFrom<AgentInterface>>::Error>
Auto Trait Implementations§
impl Forget for AgentInterface
impl Freeze for AgentInterface
impl Move for AgentInterface
impl RefUnwindSafe for AgentInterface
impl Send for AgentInterface
impl Sync for AgentInterface
impl Unpin for AgentInterface
impl UnsafeUnpin for AgentInterface
impl UnwindSafe for AgentInterface
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> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§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].