pub trait Transport:
Send
+ Sync
+ 'static {
// Required methods
fn send_request<'a>(
&'a self,
method: &'a str,
params: Value,
extra_headers: &'a HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<Value, ClientError>> + Send + 'a>>;
fn send_streaming_request<'a>(
&'a self,
method: &'a str,
params: Value,
extra_headers: &'a HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<EventStream, ClientError>> + Send + 'a>>;
// Provided methods
fn send_request_with_query<'a>(
&'a self,
method: &'a str,
params: Value,
extra_headers: &'a HashMap<String, String>,
query: &'a [(String, String)],
) -> Pin<Box<dyn Future<Output = Result<Value, ClientError>> + Send + 'a>> { ... }
fn send_streaming_request_with_query<'a>(
&'a self,
method: &'a str,
params: Value,
extra_headers: &'a HashMap<String, String>,
query: &'a [(String, String)],
) -> Pin<Box<dyn Future<Output = Result<EventStream, ClientError>> + Send + 'a>> { ... }
fn rpc_system(&self) -> Option<&'static str> { ... }
fn server_url(&self) -> Option<&str> { ... }
}Expand description
The low-level HTTP transport interface.
Implementors handle the HTTP mechanics (connection management, header
injection, body framing) and return raw JSON values or SSE streams.
Protocol-level logic (method naming, params serialization) lives in
crate::A2aClient and the methods/ modules.
§Object-safety
This trait uses Pin<Box<dyn Future<...>>> return types so that
Box<dyn Transport> is valid.
Required Methods§
Sourcefn send_request<'a>(
&'a self,
method: &'a str,
params: Value,
extra_headers: &'a HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<Value, ClientError>> + Send + 'a>>
fn send_request<'a>( &'a self, method: &'a str, params: Value, extra_headers: &'a HashMap<String, String>, ) -> Pin<Box<dyn Future<Output = Result<Value, ClientError>> + Send + 'a>>
Sends a non-streaming JSON-RPC or REST request.
Returns the result field from the JSON-RPC success response as a
raw serde_json::Value for the caller to deserialize.
The extra_headers map is injected verbatim into the HTTP request
(e.g. Authorization from an crate::auth::AuthInterceptor).
Sourcefn send_streaming_request<'a>(
&'a self,
method: &'a str,
params: Value,
extra_headers: &'a HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<EventStream, ClientError>> + Send + 'a>>
fn send_streaming_request<'a>( &'a self, method: &'a str, params: Value, extra_headers: &'a HashMap<String, String>, ) -> Pin<Box<dyn Future<Output = Result<EventStream, ClientError>> + Send + 'a>>
Sends a streaming request and returns an EventStream.
The request is sent with Accept: text/event-stream; the response body
is a Server-Sent Events stream. The returned EventStream lets the
caller iterate over a2a_protocol_types::StreamResponse events.
Provided Methods§
Sourcefn send_request_with_query<'a>(
&'a self,
method: &'a str,
params: Value,
extra_headers: &'a HashMap<String, String>,
query: &'a [(String, String)],
) -> Pin<Box<dyn Future<Output = Result<Value, ClientError>> + Send + 'a>>
fn send_request_with_query<'a>( &'a self, method: &'a str, params: Value, extra_headers: &'a HashMap<String, String>, query: &'a [(String, String)], ) -> Pin<Box<dyn Future<Output = Result<Value, ClientError>> + Send + 'a>>
send_request with query appended to the
request URL, as an API key placed in the query string needs (a2a.proto
APIKeySecurityScheme.location: “query”, “header”, or “cookie”; audit
register R67).
The default sends through send_request when query is empty and
otherwise refuses with ClientError::InvalidAuthScheme, so a
transport that cannot carry query parameters says so rather than
dropping a credential. The JSON-RPC and HTTP+JSON transports carry
them; gRPC and WebSocket refuse.
Sourcefn send_streaming_request_with_query<'a>(
&'a self,
method: &'a str,
params: Value,
extra_headers: &'a HashMap<String, String>,
query: &'a [(String, String)],
) -> Pin<Box<dyn Future<Output = Result<EventStream, ClientError>> + Send + 'a>>
fn send_streaming_request_with_query<'a>( &'a self, method: &'a str, params: Value, extra_headers: &'a HashMap<String, String>, query: &'a [(String, String)], ) -> Pin<Box<dyn Future<Output = Result<EventStream, ClientError>> + Send + 'a>>
send_streaming_request with query
appended to the request URL; see
send_request_with_query.
Sourcefn rpc_system(&self) -> Option<&'static str>
fn rpc_system(&self) -> Option<&'static str>
The rpc.system.name of this transport’s calls, which each call’s
CLIENT span carries when the transport was given to
ClientBuilder::with_custom_transport
(ADR 0013). The default, None, records none. The semantic
conventions name jsonrpc and grpc; a binding they do not list
uses its own name in lower case (slimrpc). A transport the builder
makes for a card’s binding is named by the builder, not by this.
Sourcefn server_url(&self) -> Option<&str>
fn server_url(&self) -> Option<&str>
The URL this transport’s calls go to, from which each call’s span and
rpc.client.call.duration take server.address and server.port
when the transport was given to
ClientBuilder::with_custom_transport.
The default, None, records neither, so a dashboard cannot tell this
client’s agents apart; a transport whose peer has no URL (SLIMRPC
names a SLIM identity) takes it. A transport the builder makes for a
card’s binding is addressed by the builder, not by this.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".