packet

Trait BufferViewMut

Source
pub trait BufferViewMut<B: SplitByteSliceMut>: 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: KnownLayout + Immutable + Unaligned { ... }
    fn take_obj_back_zero<T>(&mut self) -> Option<Ref<B, T>>
       where T: KnownLayout + Immutable + Unaligned { ... }
    fn write_obj_front<T>(&mut self, obj: &T) -> Option<()>
       where T: ?Sized + IntoBytes + Immutable { ... }
    fn write_obj_back<T>(&mut self, obj: &T) -> Option<()>
       where T: ?Sized + IntoBytes + Immutable { ... }
}
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: KnownLayout + Immutable + 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: KnownLayout + Immutable + 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 + IntoBytes + Immutable,

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 + IntoBytes + Immutable,

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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so 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

Source§

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