Skip to content

Commit

Permalink
docs(http/retry): document PeekTrailersBody<B> interfaces
Browse files Browse the repository at this point in the history
this is a squashed commit containing the following:

---

docs(http/retry): document `PeekTrailersBody::inner`

Signed-off-by: katelyn martin <kate@buoyant.io>

docs(http/retry): document `PeekTrailersBody::peek_trailers()`

Signed-off-by: katelyn martin <kate@buoyant.io>

docs(http/retry): document `PeekTrailersBody::no_trailers()`

Signed-off-by: katelyn martin <kate@buoyant.io>
  • Loading branch information
cratelyn committed Jan 22, 2025
1 parent 76b5f10 commit 8169b3e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions linkerd/http/retry/src/peek_trailers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ use std::{
/// If the first frame of the body stream was *not* a `TRAILERS` frame, this
/// behaves identically to a normal body.
pub struct PeekTrailersBody<B: Body = BoxBody> {
/// The inner [`Body`].
///
/// This is the request or response body whose trailers are being peeked.
inner: B,

/// The first DATA frame received from the inner body, or an error that
Expand Down Expand Up @@ -46,6 +49,10 @@ pub type WithPeekTrailersBody<B> = Either<
// === impl WithTrailers ===

impl<B: Body> PeekTrailersBody<B> {
/// Returns a reference to the body's trailers, if available.
///
/// This function will return `None` if the body's trailers could not be peeked, or if there
/// were no trailers included.
pub fn peek_trailers(&self) -> Option<&http::HeaderMap> {
self.trailers
.as_ref()
Expand Down Expand Up @@ -116,6 +123,9 @@ impl<B: Body> PeekTrailersBody<B> {
http::Response::from_parts(parts, body)
}

/// Returns a response with an inert [`PeekTrailersBody<B>`].
///
/// This will not peek the inner body's trailers.
fn no_trailers(rsp: http::Response<B>) -> http::Response<Self> {
rsp.map(|inner| Self {
inner,
Expand Down

0 comments on commit 8169b3e

Please sign in to comment.