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.

Object Safety§

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.
§

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

source§

impl<T> Buffer for VecBuffer<T>

Available on crate feature std only.
§

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.
§

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

source§

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

§

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 std and write only.
§

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.
§

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