rama::http::layer::trace

Trait OnBodyChunk

pub trait OnBodyChunk<B>:
    Send
    + Sync
    + 'static {
    // Required method
    fn on_body_chunk(&mut self, chunk: &B, latency: Duration, span: &Span);
}
Expand description

Trait used to tell Trace what to do when a body chunk has been sent.

See the module docs for details on exactly when the on_body_chunk callback is called.

Required Methods§

fn on_body_chunk(&mut self, chunk: &B, latency: Duration, span: &Span)

Do the thing.

latency is the duration since the response was sent or since the last body chunk as sent.

span is the tracing Span, corresponding to this request, produced by the closure passed to TraceLayer::make_span_with. It can be used to record field values that weren’t known when the span was created.

Implementations on Foreign Types§

§

impl<B> OnBodyChunk<B> for ()

§

fn on_body_chunk(&mut self, _: &B, _: Duration, _: &Span)

Implementors§

§

impl<B> OnBodyChunk<B> for DefaultOnBodyChunk

§

impl<B, F> OnBodyChunk<B> for F
where F: Fn(&B, Duration, &Span) + Send + Sync + 'static,