Skip to main content

AgentInterface

Struct AgentInterface 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§url: String

The 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: String

The 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: String

The 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

Source

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());
Source

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",
);
Source

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",
);
Source

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",
);
Source

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

Source

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

Source§

fn clone(&self) -> AgentInterface

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AgentInterface

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for AgentInterface

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<AgentInterface, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<AgentInterface> for AgentInterface

Source§

fn from(value: AgentInterface) -> AgentInterface

Converts to this type from the input type.
Source§

impl Serialize for AgentInterface

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<AgentInterface> for AgentInterface

Source§

type Error = ConvertError

The type returned in the event of a conversion error.
Source§

fn try_from( value: AgentInterface, ) -> Result<AgentInterface, <AgentInterface as TryFrom<AgentInterface>>::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more