Trait packet::BufferViewMut

source ·
pub trait BufferViewMut<B: ByteSliceMut>: BufferView<B> + AsMut<[u8]> {
    // Provided methods
    fn take_front_zero(&mut self, n: usize) -> Option<B> { ... }
    fn take_back_zero(&mut self, n: usize) -> Option<B> { ... }
    fn take_rest_front_zero(self) -> B { ... }
    fn take_rest_back_zero(self) -> B { ... }
    fn into_rest_zero(self) -> B { ... }
    fn take_obj_front_zero<T>(&mut self) -> Option<Ref<B, T>>
       where T: Unaligned { ... }
    fn take_obj_back_zero<T>(&mut self) -> Option<Ref<B, T>>
       where T: Unaligned { ... }
    fn write_obj_front<T>(&mut self, obj: &T) -> Option<()>
       where T: ?Sized + AsBytes + NoCell { ... }
    fn write_obj_back<T>(&mut self, obj: &T) -> Option<()>
       where T: ?Sized + AsBytes + NoCell { ... }
}
Expand description

A mutable view into a Buffer.

A BufferViewMut is a BufferView which provides mutable access to the contents of the buffer.

§Notable implementations

BufferViewMut is implemented for &mut &mut [u8].

Provided Methods§

source

fn take_front_zero(&mut self, n: usize) -> Option<B>

Takes n bytes from the front of the buffer’s body and zeroes them.

take_front_zero is like BufferView::take_front, except that it zeroes the bytes before returning them. This can be useful when serializing to ensure that the contents of packets previously stored in the buffer are not leaked.

source

fn take_back_zero(&mut self, n: usize) -> Option<B>

Takes n bytes from the back of the buffer’s body and zeroes them.

take_back_zero is like BufferView::take_back, except that it zeroes the bytes before returning them. This can be useful when serializing to ensure that the contents of packets previously stored in the buffer are not leaked.

source

fn take_rest_front_zero(self) -> B

Takes the rest of the buffer’s body from the front and zeroes it.

take_rest_front_zero is like BufferView::take_rest_front, except that it zeroes the bytes before returning them. This can be useful when serializing to ensure that the contents of packets previously stored in the buffer are not leaked.

source

fn take_rest_back_zero(self) -> B

Takes the rest of the buffer’s body from the back and zeroes it.

take_rest_back_zero is like BufferView::take_rest_back, except that it zeroes the bytes before returning them. This can be useful when serializing to ensure that the contents of packets previously stored in the buffer are not leaked.

source

fn into_rest_zero(self) -> B

Converts this view into a reference to the buffer’s body, and zeroes it.

into_rest_zero is like BufferView::into_rest, except that it zeroes the bytes before returning them. This can be useful when serializing to ensure that the contents of packets previously stored in the buffer are not leaked.

source

fn take_obj_front_zero<T>(&mut self) -> Option<Ref<B, T>>
where T: Unaligned,

Takes an object from the front of the buffer’s body and zeroes it.

take_obj_front_zero is like BufferView::take_obj_front, except that it zeroes the bytes before converting them to a T. This can be useful when serializing to ensure that the contents of packets previously stored in the buffer are not leaked.

source

fn take_obj_back_zero<T>(&mut self) -> Option<Ref<B, T>>
where T: Unaligned,

Takes an object from the back of the buffer’s body and zeroes it.

take_obj_back_zero is like BufferView::take_obj_back, except that it zeroes the bytes before converting them to a T. This can be useful when serializing to ensure that the contents of packets previously stored in the buffer are not leaked.

source

fn write_obj_front<T>(&mut self, obj: &T) -> Option<()>
where T: ?Sized + AsBytes + NoCell,

Writes an object to the front of the buffer’s body, consuming the bytes.

write_obj_front consumes size_of_val(obj) bytes from the front of the buffer’s body, and overwrites them with obj. After a successful call to write_obj_front(obj), the body is size_of_val(obj) bytes shorter and, if Self: GrowBuffer, the prefix is size_of_val(obj) bytes longer. If the body is not at least size_of_val(obj) bytes in length, write_obj_front returns None.

source

fn write_obj_back<T>(&mut self, obj: &T) -> Option<()>
where T: ?Sized + AsBytes + NoCell,

Writes an object to the back of the buffer’s body, consuming the bytes.

write_obj_back consumes size_of_val(obj) bytes from the back of the buffer’s body, and overwrites them with obj. After a successful call to write_obj_back(obj), the body is size_of_val(obj) bytes shorter and, if Self: GrowBuffer, the suffix is size_of_val(obj) bytes longer. If the body is not at least size_of_val(obj) bytes in length, write_obj_back returns None.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<'b, 'a: 'b> BufferViewMut<&'b mut [u8]> for &'b mut &'a mut [u8]

Implementors§

source§

impl<'a> BufferViewMut<&'a mut [u8]> for BufViewMut<'a>

source§

impl<'a> BufferViewMut<&'a mut [u8]> for EmptyBuf