Skip to content

Commit 2f45d53

Browse files
committed
feat(body): add Body::is_empty() method
1 parent b79f8d3 commit 2f45d53

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/proto/body.rs

+16
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,22 @@ impl Body {
4949
let (tx, rx) = channel();
5050
(tx.tx, rx)
5151
}
52+
53+
/// Returns if this body was constructed via `Body::empty()`.
54+
///
55+
/// # Note
56+
///
57+
/// This does **not** detect if the body stream may be at the end, or
58+
/// if the stream will not yield any chunks, in all cases. For instance,
59+
/// a streaming body using `chunked` encoding is not able to tell if
60+
/// there are more chunks immediately.
61+
#[inline]
62+
pub fn is_empty(&self) -> bool {
63+
match self.0 {
64+
Inner::Empty => true,
65+
_ => false,
66+
}
67+
}
5268
}
5369

5470
impl Default for Body {

0 commit comments

Comments
 (0)