Trait tokio_io_utility::Container
source · pub trait Container {
// Required methods
fn reserve(&mut self, n: usize);
fn len(&self) -> usize;
fn capacity(&self) -> usize;
unsafe fn spare_mut(&mut self) -> &mut [MaybeUninit<u8>];
unsafe fn advance(&mut self, n: usize);
// Provided method
fn is_empty(&self) -> bool { ... }
}
Required Methods§
sourcefn reserve(&mut self, n: usize)
fn reserve(&mut self, n: usize)
Reserve at least n
bytes that can be used in
Container::spare_mut
.
sourceunsafe fn spare_mut(&mut self) -> &mut [MaybeUninit<u8>]
unsafe fn spare_mut(&mut self) -> &mut [MaybeUninit<u8>]
The returned uninit slice must not be empty.
NOTE that the returned uninit slice might be smaller
than bytes reserved in Container::reserve
or
(Container::capacity
- Container::len
).
This is because that the container might be a ring buffer.
If you consume all uninit slices, then the sum of their lengths
must be equal to the spare capacity (Container::capacity
-
Container::len
).
Safety
The slice returned must not be read from and users should never write uninitialized bytes to it.
sourceunsafe fn advance(&mut self, n: usize)
unsafe fn advance(&mut self, n: usize)
Safety
The users must have actually initialized at least n
bytes
in the uninit slice returned by Container::spare_mut
.