Skip to main content

SetLen

Trait SetLen 

Source
pub trait SetLen {
    // Required method
    unsafe fn set_len(&mut self, len: usize);

    // 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

A helper trait for set_len like methods.

Required Methods§

Source

unsafe fn set_len(&mut self, len: usize)

Set the buffer length.

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

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", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl SetLen for ()

Source§

unsafe fn set_len(&mut self, len: usize)

Source§

impl SetLen for BorrowedBuf<'static>

Available on crate feature read_buf only.
Source§

unsafe fn set_len(&mut self, len: usize)

Source§

impl SetLen for BytesMut

Available on crate feature bytes only.
Source§

unsafe fn set_len(&mut self, len: usize)

Source§

impl SetLen for [u8]

Source§

unsafe fn set_len(&mut self, len: usize)

Source§

impl<A: Allocator + 'static> SetLen for Vec<u8, A>

Source§

unsafe fn set_len(&mut self, len: usize)

Source§

impl<B: SetLen + ?Sized> SetLen for &'static mut B

Source§

unsafe fn set_len(&mut self, len: usize)

Source§

impl<B: SetLen + ?Sized, A: Allocator + 'static> SetLen for Box<B, A>

Source§

unsafe fn set_len(&mut self, len: usize)

Source§

impl<T: IoBufMut> SetLen for [T]

Source§

unsafe fn set_len(&mut self, len: usize)

Source§

impl<T: IoBufMut> SetLen for (T,)

Source§

unsafe fn set_len(&mut self, len: usize)

Source§

impl<T: IoBufMut, A: Allocator + 'static> SetLen for Vec<T, A>

Source§

unsafe fn set_len(&mut self, len: usize)

Source§

impl<T: IoBufMut, Rest: IoVectoredBufMut> SetLen for (T, Rest)

Source§

unsafe fn set_len(&mut self, len: usize)

Source§

impl<T: IoBufMut, const N: usize> SetLen for [T; N]

Source§

unsafe fn set_len(&mut self, len: usize)

Source§

impl<T: IoBufMut, const N: usize> SetLen for ArrayVec<T, N>

Available on crate feature arrayvec only.
Source§

unsafe fn set_len(&mut self, len: usize)

Source§

impl<T: IoBufMut, const N: usize> SetLen for SmallVec<[T; N]>
where [T; N]: Array<Item = T>,

Available on crate feature smallvec only.
Source§

unsafe fn set_len(&mut self, len: usize)

Source§

impl<const N: usize> SetLen for ArrayVec<u8, N>

Available on crate feature arrayvec only.
Source§

unsafe fn set_len(&mut self, len: usize)

Source§

impl<const N: usize> SetLen for SmallVec<[u8; N]>
where [u8; N]: Array<Item = u8>,

Available on crate feature smallvec only.
Source§

unsafe fn set_len(&mut self, len: usize)

Source§

impl<const N: usize> SetLen for [u8; N]

Source§

unsafe fn set_len(&mut self, len: usize)

Implementors§