Struct timely::communication::allocator::zero_copy::bytes_slab::BytesSlab
source · pub struct BytesSlab { /* private fields */ }
Expand description
A large binary allocation for writing and sharing.
A bytes slab wraps a Bytes
and maintains a valid (written) length, and supports writing after
this valid length, and extracting Bytes
up to this valid length. Extracted bytes are enqueued
and checked for uniqueness in order to recycle them (once all shared references are dropped).
Implementations§
source§impl BytesSlab
impl BytesSlab
sourcepub fn new(shift: usize) -> BytesSlab
pub fn new(shift: usize) -> BytesSlab
Allocates a new BytesSlab
with an initial size determined by a shift.
sourcepub fn make_valid(&mut self, bytes: usize)
pub fn make_valid(&mut self, bytes: usize)
Marks the next bytes
bytes as valid.
sourcepub fn ensure_capacity(&mut self, capacity: usize)
pub fn ensure_capacity(&mut self, capacity: usize)
Ensures that self.empty().len()
is at least capacity
.
This method may retire the current buffer if it does not have enough space, in which case it will copy any remaining contents into a new buffer. If this would not create enough free space, the shift is increased until it is sufficient.
Auto Trait Implementations§
impl Freeze for BytesSlab
impl !RefUnwindSafe for BytesSlab
impl Send for BytesSlab
impl !Sync for BytesSlab
impl Unpin for BytesSlab
impl !UnwindSafe for BytesSlab
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