pub trait CostRecorder:
Send
+ Sync
+ Debug {
// Required method
fn record<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 ConnectionContext,
response_body: &'life2 Value,
) -> Pin<Box<dyn Future<Output = Result<(), ProxyError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
}Expand description
Post-response cost recording hook.
Called after the on_response middleware chain completes and before the
axum response is built. Implementors (typically the cost crate) use this
to extract usage, calculate cost, and persist a CostRecord.
This is deliberately not part of ProxyMiddleware because cost recording
needs to happen after ALL other response transformations are done.
Required Methods§
Sourcefn record<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 ConnectionContext,
response_body: &'life2 Value,
) -> Pin<Box<dyn Future<Output = Result<(), ProxyError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn record<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 ConnectionContext,
response_body: &'life2 Value,
) -> Pin<Box<dyn Future<Output = Result<(), ProxyError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Record a cost entry for the completed request.
response_body is the final response body JSON (after all middleware
transforms have been applied).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".