pub struct InterceptorChain<T = ()> { /* private fields */ }Expand description
A chain of interceptors that are executed in order.
This struct manages multiple interceptors and ensures they are called in the correct order for each lifecycle event.
The generic type parameter T defines the state type that will be passed
through the request lifecycle. Use () (the default) for interceptors
that don’t need to maintain state.
Implementations§
Source§impl<T> InterceptorChain<T>
impl<T> InterceptorChain<T>
Sourcepub fn add(&mut self, interceptor: Box<dyn Interceptor<T>>)
pub fn add(&mut self, interceptor: Box<dyn Interceptor<T>>)
Add an interceptor to the chain.
Interceptors are executed in the order they are added.
Sourcepub async fn before_request(
&self,
ctx: &mut BeforeRequestContext<'_, T>,
) -> Result<()>
pub async fn before_request( &self, ctx: &mut BeforeRequestContext<'_, T>, ) -> Result<()>
Execute the before_request hook for all interceptors.
Sourcepub async fn after_response(
&self,
ctx: &AfterResponseContext<'_, T>,
) -> Result<()>where
T: Sync,
pub async fn after_response(
&self,
ctx: &AfterResponseContext<'_, T>,
) -> Result<()>where
T: Sync,
Execute the after_response hook for all interceptors.
Sourcepub async fn on_stream_chunk(
&self,
ctx: &StreamChunkContext<'_, T>,
) -> Result<()>where
T: Sync,
pub async fn on_stream_chunk(
&self,
ctx: &StreamChunkContext<'_, T>,
) -> Result<()>where
T: Sync,
Execute the on_stream_chunk hook for all interceptors.
Sourcepub async fn on_stream_end(&self, ctx: &StreamEndContext<'_, T>) -> Result<()>where
T: Sync,
pub async fn on_stream_end(&self, ctx: &StreamEndContext<'_, T>) -> Result<()>where
T: Sync,
Execute the on_stream_end hook for all interceptors.
Sourcepub async fn on_error(&self, ctx: &ErrorContext<'_, T>)where
T: Sync,
pub async fn on_error(&self, ctx: &ErrorContext<'_, T>)where
T: Sync,
Execute the on_error hook for all interceptors.
Errors in individual interceptors are ignored to prevent cascading failures during error handling.