Skip to main content

SetLenExt

Trait SetLenExt 

Source
pub trait SetLenExt: SetLen {
    // Provided methods
    unsafe fn advance(&mut self, len: usize)
       where Self: IoBuf { ... }
    unsafe fn advance_to(&mut self, len: usize)
       where Self: IoBuf { ... }
    unsafe fn advance_vec_to(&mut self, len: usize)
       where Self: IoVectoredBuf { ... }
    fn clear(&mut self)
       where Self: IoBuf { ... }
}
Expand description

Extension trait for set_len like methods.

Provided Methods§

Source

unsafe fn advance(&mut self, len: usize)
where Self: IoBuf,

Advance the buffer length by len.

§Safety
  • The bytes in the range [buf_len(), buf_len() + len) must be initialized.
Source

unsafe fn advance_to(&mut self, len: usize)
where Self: IoBuf,

Set the buffer length to len. If len is less than the current length, this operation is a no-op.

§Safety
  • len must be less or equal than as_uninit().len().
  • The bytes in the range [buf_len(), len) must be initialized.
Source

unsafe fn advance_vec_to(&mut self, len: usize)
where Self: IoVectoredBuf,

Set the vector buffer’s total length to len. If len is less than the current total length, this operation is a no-op.

§Safety
  • len must be less or equal than total_len().
  • The bytes in the range [total_len(), len) must be initialized.
Source

fn clear(&mut self)
where Self: IoBuf,

Clear the buffer, setting its length to 0 without touching its content or capacity.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<B> SetLenExt for B
where B: SetLen + ?Sized,