Skip to content

Commit

Permalink
feat(body): add Body::is_empty() method
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed Feb 24, 2018
1 parent b79f8d3 commit 2f45d53
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/proto/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ impl Body {
let (tx, rx) = channel();
(tx.tx, rx)
}

/// Returns if this body was constructed via `Body::empty()`.
///
/// # Note
///
/// This does **not** detect if the body stream may be at the end, or
/// if the stream will not yield any chunks, in all cases. For instance,
/// a streaming body using `chunked` encoding is not able to tell if
/// there are more chunks immediately.
#[inline]
pub fn is_empty(&self) -> bool {
match self.0 {
Inner::Empty => true,
_ => false,
}
}
}

impl Default for Body {
Expand Down

0 comments on commit 2f45d53

Please sign in to comment.