[][src]Trait buf_min::Buffer

pub trait Buffer {
    type Freeze;
    fn with_capacity(capacity: usize) -> Self
    where
        Self: Sized
;
fn extend_from_slice(&mut self, src: &[u8]);
fn reserve(&mut self, additional: usize);
fn freeze(self) -> Self::Freeze;
unsafe fn advance(&mut self, cnt: usize);
unsafe fn buf_ptr(&mut self) -> *mut u8; }

Minimal Buffer trait

Associated Types

type Freeze

Into immutable type

Loading content...

Required methods

fn with_capacity(capacity: usize) -> Self where
    Self: Sized

Returns new Buffer with capacity

fn extend_from_slice(&mut self, src: &[u8])

Appends given bytes to this Buffer.

Panics

Can panic if current length plus src length overflows usize

fn reserve(&mut self, additional: usize)

Reserves capacity for at least additional more bytes to be inserted into the given Buffer.

Panics

Can panic if current capacity plus additional overflows usize

fn freeze(self) -> Self::Freeze

Converts self into a Freeze type

unsafe fn advance(&mut self, cnt: usize)

Advance the internal cursor of the Buffer

Safety

Can't advance more than capacity of the Buffer

Panics

Can panic if length plus cnt is bigger than capacity

unsafe fn buf_ptr(&mut self) -> *mut u8

Return unsafe ptr to current Buffer position

Safety

If buffer is full, can return invalid pointer

Loading content...

Implementations on Foreign Types

impl Buffer for BytesMut[src]

type Freeze = Bytes

Loading content...

Implementors

Loading content...