pub trait CallInterceptor:
Send
+ Sync
+ 'static {
// Required methods
fn before<'a>(
&'a self,
req: &'a mut ClientRequest,
) -> impl Future<Output = ClientResult<()>> + Send + 'a;
fn after<'a>(
&'a self,
resp: &'a ClientResponse,
) -> impl Future<Output = ClientResult<()>> + Send + 'a;
}Expand description
Hooks called before every A2A request and after every response.
Implement this trait to add cross-cutting concerns such as authentication,
logging, or metrics. Register interceptors via
crate::ClientBuilder::with_interceptor.
§Object-safety note
This trait uses impl Future return types with explicit lifetimes, which
is not object-safe. Internally the SDK wraps implementations in a
boxed-future shim. Callers implement the ergonomic trait API.
Required Methods§
Sourcefn before<'a>(
&'a self,
req: &'a mut ClientRequest,
) -> impl Future<Output = ClientResult<()>> + Send + 'a
fn before<'a>( &'a self, req: &'a mut ClientRequest, ) -> impl Future<Output = ClientResult<()>> + Send + 'a
Called before the request is sent.
Mutate req to modify parameters or inject headers.
Sourcefn after<'a>(
&'a self,
resp: &'a ClientResponse,
) -> impl Future<Output = ClientResult<()>> + Send + 'a
fn after<'a>( &'a self, resp: &'a ClientResponse, ) -> impl Future<Output = ClientResult<()>> + Send + 'a
Called after a successful response is received.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.