Trait Buffer

Source
pub unsafe trait Buffer: Default {
    type Slice<'a>
       where Self: 'a;

    // Required methods
    fn capacity(&self) -> usize;
    unsafe fn slice(&mut self, range: Range<usize>) -> Self::Slice<'_>;
    unsafe fn clear(&mut self, range: Range<usize>);
}
Expand description

Queue buffer. It is used together with InsertIntoBuffer.

§Safety

Buffer::clear clears the inserted range from the buffer (see InsertIntoBuffer::insert_into), meaning new values can be inserted.

Required Associated Types§

Source

type Slice<'a> where Self: 'a

The slice type returned by slice method.

Required Methods§

Source

fn capacity(&self) -> usize

Returns the buffer’s capacity.

Source

unsafe fn slice(&mut self, range: Range<usize>) -> Self::Slice<'_>

Returns a slice of the buffer.

§Safety

Range must have been inserted (see InsertIntoBuffer::insert_into) before calling this method.

Source

unsafe fn clear(&mut self, range: Range<usize>)

Clears the buffer.

§Safety

Range must have been inserted (see InsertIntoBuffer::insert_into) before calling this method.

Calling this method clears the inserted value, meaning new values can be inserted.

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.

Implementors§

Source§

impl<T> Buffer for WriteVectoredVecBuffer<T>
where T: AsRef<[u8]>,

Available on crate features write and std only.
Source§

type Slice<'a> = VectoredSlice<'a> where T: 'a

Source§

impl<T> Buffer for VecBuffer<T>

Available on crate feature alloc only.
Source§

type Slice<'a> = &'a mut [T] where T: 'a

Source§

impl<T, const N: usize> Buffer for WriteVectoredArrayBuffer<T, N>
where T: AsRef<[u8]>,

Available on crate features write and std only.
Source§

type Slice<'a> = VectoredSlice<'a> where T: 'a

Source§

impl<T, const N: usize> Buffer for ArrayBuffer<T, N>

Source§

type Slice<'a> = &'a mut [T] where T: 'a

Source§

impl<const HEADER_SIZE: usize, const TRAILER_SIZE: usize> Buffer for WriteVecBuffer<HEADER_SIZE, TRAILER_SIZE>

Available on crate features alloc and write only.
Source§

type Slice<'a> = BytesSlice<'a, HEADER_SIZE, TRAILER_SIZE>

Source§

impl<const N: usize, const HEADER_SIZE: usize, const TRAILER_SIZE: usize> Buffer for WriteArrayBuffer<N, HEADER_SIZE, TRAILER_SIZE>

Available on crate feature write only.
Source§

type Slice<'a> = BytesSlice<'a, HEADER_SIZE, TRAILER_SIZE>