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§
Sourcefn encode_request(&self, operation: &A2AOperation) -> Result<Bytes, A2AError>
fn encode_request(&self, operation: &A2AOperation) -> Result<Bytes, A2AError>
Sourcefn decode_response(
&self,
body: &[u8],
operation: &A2AOperation,
) -> Result<A2AResponse, A2AError>
fn decode_response( &self, body: &[u8], operation: &A2AOperation, ) -> Result<A2AResponse, A2AError>
Sourcefn content_type(&self) -> &str
fn content_type(&self) -> &str
Get the content type for this codec
§Returns
The MIME type (e.g., “application/json”, “application/protobuf”)