Struct timely::communication::allocator::zero_copy::bytes_slab::BytesSlab [−][src]
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
impl BytesSlab
[src]
pub fn new(shift: usize) -> BytesSlab
[src]
Allocates a new BytesSlab
with an initial size determined by a shift.
pub fn empty(&mut self) -> &mut [u8]ⓘ
[src]
The empty region of the slab.
pub fn valid(&mut self) -> &mut [u8]ⓘ
[src]
The valid region of the slab.
pub fn make_valid(&mut self, bytes: usize)
[src]
Marks the next bytes
bytes as valid.
pub fn extract(&mut self, bytes: usize) -> Bytes
[src]
Extracts the first bytes
valid bytes.
pub fn ensure_capacity(&mut self, capacity: usize)
[src]
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 !RefUnwindSafe for BytesSlab
impl Send for BytesSlab
impl !Sync for BytesSlab
impl Unpin for BytesSlab
impl !UnwindSafe for BytesSlab
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,