pub trait Buffer {
type Freeze;
// Required methods
fn with_capacity(capacity: usize) -> Self
where Self: Sized;
fn is_empty(&self) -> bool;
fn len(&self) -> usize;
unsafe 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;
// Provided method
fn extend(&mut self, src: &str) { ... }
}
Expand description
Minimal Buffer trait with utf-8 safety
Required Associated Types§
Required Methods§
Sourcefn with_capacity(capacity: usize) -> Selfwhere
Self: Sized,
fn with_capacity(capacity: usize) -> Selfwhere
Self: Sized,
Returns new Buffer
with capacity
fn len(&self) -> usize
Sourceunsafe fn extend_from_slice(&mut self, src: &[u8])
unsafe fn extend_from_slice(&mut self, src: &[u8])
Sourcefn reserve(&mut self, additional: 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