pub struct TimingMiddleware { /* private fields */ }Expand description
Timing middleware: invokes a user-supplied callback with the elapsed duration after each successful response.
Useful for recording latency metrics without coupling to any particular metrics framework.
§Example
use std::sync::Arc;
use std::sync::Mutex;
use oxihttp_client::middleware::TimingMiddleware;
let recorded = Arc::new(Mutex::new(Vec::new()));
let r = Arc::clone(&recorded);
let mw = TimingMiddleware::new(move |d| r.lock().expect("lock").push(d));Implementations§
Trait Implementations§
Source§impl ClientMiddleware for TimingMiddleware
impl ClientMiddleware for TimingMiddleware
Source§fn before_request(&self, _ctx: &RequestContext<'_>)
fn before_request(&self, _ctx: &RequestContext<'_>)
Called immediately before the first network attempt.
Source§fn after_response(&self, ctx: &ResponseContext)
fn after_response(&self, ctx: &ResponseContext)
Called after a successful response is obtained (including after retries).
Auto Trait Implementations§
impl Freeze for TimingMiddleware
impl !RefUnwindSafe for TimingMiddleware
impl Send for TimingMiddleware
impl Sync for TimingMiddleware
impl Unpin for TimingMiddleware
impl UnsafeUnpin for TimingMiddleware
impl !UnwindSafe for TimingMiddleware
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more