Struct object_store::PutPayloadMut
source · pub struct PutPayloadMut { /* private fields */ }
Expand description
A builder for PutPayload
that avoids reallocating memory
Data is allocated in fixed blocks, which are flushed to Bytes
once full.
Unlike Vec
this avoids needing to repeatedly reallocate blocks of memory,
which typically involves copying all the previously written data to a new
contiguous memory region.
Implementations§
source§impl PutPayloadMut
impl PutPayloadMut
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new PutPayloadMut
sourcepub fn with_block_size(self, block_size: usize) -> Self
pub fn with_block_size(self, block_size: usize) -> Self
Configures the minimum allocation size
Defaults to 8KB
sourcepub fn extend_from_slice(&mut self, slice: &[u8])
pub fn extend_from_slice(&mut self, slice: &[u8])
Write bytes into this PutPayloadMut
If there is an in-progress block, data will be first written to it, flushing
it to Bytes
once full. If data remains to be written, a new block of memory
of at least the configured block size will be allocated, to hold the remaining data.
sourcepub fn push(&mut self, bytes: Bytes)
pub fn push(&mut self, bytes: Bytes)
Append a Bytes
to this PutPayloadMut
without copying
This will close any currently buffered block populated by Self::extend_from_slice
,
and append bytes
to this payload without copying.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
if this PutPayloadMut
contains no bytes
sourcepub fn content_length(&self) -> usize
pub fn content_length(&self) -> usize
Returns the total length of the Bytes
in this payload
sourcepub fn freeze(self) -> PutPayload
pub fn freeze(self) -> PutPayload
Convert into PutPayload
Trait Implementations§
source§impl Debug for PutPayloadMut
impl Debug for PutPayloadMut
source§impl Default for PutPayloadMut
impl Default for PutPayloadMut
source§impl From<PutPayloadMut> for PutPayload
impl From<PutPayloadMut> for PutPayload
source§fn from(value: PutPayloadMut) -> Self
fn from(value: PutPayloadMut) -> Self
Auto Trait Implementations§
impl Freeze for PutPayloadMut
impl RefUnwindSafe for PutPayloadMut
impl Send for PutPayloadMut
impl Sync for PutPayloadMut
impl Unpin for PutPayloadMut
impl UnwindSafe for PutPayloadMut
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
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>
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>
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