Skip to main content

Transport

Trait Transport 

Source
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>>;
}
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§

Source

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).

Source

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.

Implementors§