Codec

Trait Codec 

Source
pub trait Codec: Send + Sync {
    // Required methods
    fn encode_request(
        &self,
        operation: &A2AOperation,
    ) -> Result<Bytes, A2AError>;
    fn decode_response(
        &self,
        body: &[u8],
        operation: &A2AOperation,
    ) -> Result<A2AResponse, A2AError>;
    fn content_type(&self) -> &str;
}
Expand description

Codec trait for encoding and decoding A2A protocol messages

Different codecs implement different protocol bindings (HTTP+JSON, gRPC+Protobuf, etc.)

Required Methods§

Source

fn encode_request(&self, operation: &A2AOperation) -> Result<Bytes, A2AError>

Serialize an A2A operation to bytes for transport

§Arguments
  • operation - The A2A operation to encode
§Returns

The serialized bytes or an error

Source

fn decode_response( &self, body: &[u8], operation: &A2AOperation, ) -> Result<A2AResponse, A2AError>

Deserialize transport response bytes to an A2A response

§Arguments
  • body - The response body bytes
  • operation - The original operation (for context)
§Returns

The deserialized A2A response or an error

Source

fn content_type(&self) -> &str

Get the content type for this codec

§Returns

The MIME type (e.g., “application/json”, “application/protobuf”)

Implementors§