pub struct AgentInterface {
pub url: String,
pub protocol_binding: String,
pub protocol_version: String,
pub tenant: Option<String>,
}Expand description
A transport interface offered by an agent.
Fields§
§url: StringBase URL of this interface endpoint.
protocol_binding: StringProtocol binding identifier — the spec’s canonical values are
"JSONRPC", "GRPC", and "HTTP+JSON" (§5.3); custom bindings such
as "WEBSOCKET" are permitted (§12).
protocol_version: StringA2A protocol version string in Major.Minor form (e.g. "1.0").
Spec §3.6: patch version numbers SHOULD NOT be used in Agent Cards.
tenant: Option<String>Optional tenant identifier for multi-tenancy.
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); "WEBSOCKET" and other custom values are
permitted (§12). Prefer Self::jsonrpc, Self::grpc or
Self::rest over spelling 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"));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 Freeze 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§
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
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>,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request