Trait packet::GrowBufferMut

source ·
pub trait GrowBufferMut: GrowBuffer + FragmentedBufferMut {
    // Required method
    fn with_parts_mut<O, F>(&mut self, f: F) -> O
       where F: for<'a, 'b> FnOnce(&'a mut [u8], FragmentedBytesMut<'a, 'b>, &'a mut [u8]) -> O;

    // Provided methods
    fn grow_front_zero(&mut self, n: usize) { ... }
    fn grow_back_zero(&mut self, n: usize) { ... }
    fn reset_zero(&mut self) { ... }
}
Expand description

A GrowBuffer which provides mutable access to its contents.

While a GrowBuffer allows the ranges covered by its prefix, body, and suffix to be modified, it only provides immutable access to their contents. A GrowBufferMut, on the other hand, provides mutable access to the contents of its prefix, body, and suffix.

Required Methods§

source

fn with_parts_mut<O, F>(&mut self, f: F) -> O
where F: for<'a, 'b> FnOnce(&'a mut [u8], FragmentedBytesMut<'a, 'b>, &'a mut [u8]) -> O,

Gets a mutable view into the parts of this GrowBufferMut.

Calls f, passing the prefix, body, and suffix as arguments (in that order).

Provided Methods§

source

fn grow_front_zero(&mut self, n: usize)

Extends the front of the body towards the beginning of the buffer, zeroing the new bytes.

grow_front_zero calls GrowBuffer::grow_front and sets the newly-added bytes to 0. This can be useful when serializing to ensure that the contents of packets previously stored in the buffer are not leaked.

source

fn grow_back_zero(&mut self, n: usize)

Extends the back of the body towards the end of the buffer, zeroing the new bytes.

grow_back_zero calls GrowBuffer::grow_back and sets the newly-added bytes to 0. This can be useful when serializing to ensure that the contents of packets previously stored in the buffer are not leaked.

source

fn reset_zero(&mut self)

Resets the body to be equal to the entire buffer, zeroing the new bytes.

Like GrowBuffer::reset, reset_zero consumes the entire prefix and suffix, adding them to the body. It sets these bytes to 0. This can be useful when serializing to ensure that the contents of packets previously stored in the buffer are not leaked.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl GrowBufferMut for Infallible

source§

fn with_parts_mut<O, F>(&mut self, _f: F) -> O
where F: for<'a, 'b> FnOnce(&'a mut [u8], FragmentedBytesMut<'a, 'b>, &'a mut [u8]) -> O,

Implementors§