pub enum DocPayload<'a> {
Borrowed(&'a [u8]),
Mapped(MmapView<'a>),
Owned(Bytes),
Stream(ByteStream<'a>),
}Expand description
The body of a fetched document, in whichever representation avoids a copy.
Variants§
Borrowed(&'a [u8])
Borrowed directly from the caller’s buffer — zero copy.
Mapped(MmapView<'a>)
A memory-mapped view (e.g. a local file) — zero copy.
Owned(Bytes)
An owned, reference-counted buffer (e.g. a network fetch).
Stream(ByteStream<'a>)
A lazily-produced byte stream for large bodies.
Implementations§
Source§impl DocPayload<'_>
impl DocPayload<'_>
Sourcepub fn as_slice(&self) -> Option<&[u8]>
pub fn as_slice(&self) -> Option<&[u8]>
Borrow the bytes if they are already materialized in memory.
Returns None for DocPayload::Stream, which must be consumed via
DocPayload::into_bytes.
Sourcepub fn is_empty(&self) -> Option<bool>
pub fn is_empty(&self) -> Option<bool>
Whether an in-memory payload is empty (always None for streams).
Sourcepub async fn into_bytes(self) -> Result<Bytes>
pub async fn into_bytes(self) -> Result<Bytes>
Collect the payload into a contiguous Bytes, draining a stream if needed.
Trait Implementations§
Auto Trait Implementations§
impl<'a> !Freeze for DocPayload<'a>
impl<'a> !RefUnwindSafe for DocPayload<'a>
impl<'a> !Sync for DocPayload<'a>
impl<'a> !UnwindSafe for DocPayload<'a>
impl<'a> Send for DocPayload<'a>
impl<'a> Unpin for DocPayload<'a>
impl<'a> UnsafeUnpin for DocPayload<'a>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more