pub enum Body {
Empty,
Full(FullBody),
Stream(StreamBody),
}Expand description
The body type for requests and responses in the OxiHTTP stack.
This enum supports three modes:
Empty: No body content.Full: A body fully buffered in memory asBytes.Stream: A streaming body backed by an async byte stream.
Variants§
Empty
An empty body with no content.
Full(FullBody)
A body fully loaded in memory.
Stream(StreamBody)
A streaming body. The inner stream is opaque.
Implementations§
Source§impl Body
impl Body
Sourcepub fn stream(
inner: Pin<Box<dyn Stream<Item = Result<Bytes, OxiHttpError>> + Send>>,
) -> Self
pub fn stream( inner: Pin<Box<dyn Stream<Item = Result<Bytes, OxiHttpError>> + Send>>, ) -> Self
Create a streaming body from a pinned async byte-chunk stream.
Sourcepub fn content_length(&self) -> Option<u64>
pub fn content_length(&self) -> Option<u64>
Returns the content length if known.
Returns Some(0) for empty bodies, Some(n) for full bodies,
and None for streams (unknown length).
Sourcepub fn into_pinned(self) -> PinnedBody
pub fn into_pinned(self) -> PinnedBody
Convert this Body into a PinnedBody suitable for use with http_body::Body.
Trait Implementations§
Source§impl From<Body> for PinnedBody
impl From<Body> for PinnedBody
Auto Trait Implementations§
impl !Freeze for Body
impl !RefUnwindSafe for Body
impl !Sync for Body
impl !UnwindSafe for Body
impl Send for Body
impl Unpin for Body
impl UnsafeUnpin for Body
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