pub unsafe trait Buf: Sized {
const ALIGN: usize;
Show 13 methods
// Required methods
fn empty() -> Self;
fn as_ptr(&self) -> *const u8;
fn as_mut_ptr(&mut self) -> *mut u8;
fn as_bytes(&self) -> &[u8];
fn len(&self) -> u32;
fn capacity(&self) -> u32;
fn resize(&mut self, new_len: u32, fill: u8);
fn reserve(&mut self, additional: u32);
fn extend_from_slice(&mut self, data: &[u8]);
// Provided methods
fn is_empty(&self) -> bool { ... }
fn align_to(&mut self, align: usize) { ... }
fn alloc<U: Flat>(&mut self) -> Pos { ... }
fn expose_provenance(&self) { ... }
}Expand description
Required Associated Constants§
Required Methods§
Sourcefn as_mut_ptr(&mut self) -> *mut u8
fn as_mut_ptr(&mut self) -> *mut u8
Mutable raw pointer to the buffer start.
Sourcefn resize(&mut self, new_len: u32, fill: u8)
fn resize(&mut self, new_len: u32, fill: u8)
Grow or shrink the buffer, filling new bytes with fill.
Sourcefn extend_from_slice(&mut self, data: &[u8])
fn extend_from_slice(&mut self, data: &[u8])
Append bytes from a slice.
Provided Methods§
Sourcefn alloc<U: Flat>(&mut self) -> Pos
fn alloc<U: Flat>(&mut self) -> Pos
Align + allocate space for one U, return its position.
§Compile-time invariant
align_of::<U>() <= ALIGN — the buffer base is aligned to ALIGN
(at least 8), so any position that is a multiple of align_of::<U>() yields
a correctly aligned absolute address.
Sourcefn expose_provenance(&self)
fn expose_provenance(&self)
Expose provenance so Near::get can recover it
via with_exposed_provenance.
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.