[−]Trait yarte::Buffer
Minimal Buffer trait
Associated Types
type Freeze
Into immutable type
Required methods
fn with_capacity(capacity: usize) -> Self
Returns new Buffer
with capacity
fn is_empty(&self) -> bool
Returns true if the Buffer
has a length of 0.
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
Implementations on Foreign Types
impl Buffer for Vec<u8>
type Freeze = Vec<u8>
pub fn with_capacity(capacity: usize) -> Vec<u8> where
Vec<u8>: Sized,
Vec<u8>: Sized,
pub fn is_empty(&self) -> bool
pub fn extend_from_slice(&mut self, src: &[u8])
pub fn reserve(&mut self, additional: usize)
pub fn freeze(self) -> <Vec<u8> as Buffer>::Freeze
pub unsafe fn advance(&mut self, cnt: usize)
pub unsafe fn buf_ptr(&mut self) -> *mut u8
impl Buffer for BytesMut
type Freeze = Bytes
pub fn with_capacity(capacity: usize) -> BytesMut where
BytesMut: Sized,
BytesMut: Sized,