pub enum ResponseBody {
Bytes(Bytes),
File {
file: File,
size: u64,
},
}Expand description
A response body. Most handlers return ResponseBody::Bytes built from
an in-memory Bytes buffer; the File variant
exists so large disk-backed objects can be streamed straight from the
filesystem to the HTTP body without being materialized into RAM. The file
handle is opened by the service handler while it still holds the
per-bucket read guard, so the reader sees a consistent inode even if a
concurrent PUT/DELETE renames or unlinks the path before dispatch streams
the body.
Variants§
Implementations§
Source§impl ResponseBody
impl ResponseBody
pub fn len(&self) -> u64
pub fn is_empty(&self) -> bool
Sourcepub fn expect_bytes(&self) -> &[u8] ⓘ
pub fn expect_bytes(&self) -> &[u8] ⓘ
Accessor that returns the bytes of a Bytes variant and panics for
File. Used by tests and by callers that know the response was built
from an in-memory buffer (JSON handlers, cross-service glue).
Trait Implementations§
Source§impl Debug for ResponseBody
impl Debug for ResponseBody
Source§impl Default for ResponseBody
impl Default for ResponseBody
Source§impl From<&'static [u8]> for ResponseBody
impl From<&'static [u8]> for ResponseBody
Source§impl From<&'static str> for ResponseBody
impl From<&'static str> for ResponseBody
Source§impl From<Bytes> for ResponseBody
impl From<Bytes> for ResponseBody
Source§impl From<String> for ResponseBody
impl From<String> for ResponseBody
Source§impl PartialEq<Bytes> for ResponseBody
impl PartialEq<Bytes> for ResponseBody
Auto Trait Implementations§
impl !Freeze for ResponseBody
impl !RefUnwindSafe for ResponseBody
impl Send for ResponseBody
impl Sync for ResponseBody
impl Unpin for ResponseBody
impl UnsafeUnpin for ResponseBody
impl UnwindSafe for ResponseBody
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