pub trait Buffer<'a>: Sized + 'a {
// Required methods
fn empty() -> Self;
fn length(&self) -> usize;
fn split_at(self, index: usize) -> Option<[Self; 2]>;
fn copy_from_slice_exact(self, src: &[u8]) -> Result<()>;
fn zero_out(self) -> Result<()>;
}
Expand description
Abstraction between &mut u8 and the kernel’s UserSliceWo.
Required Methods§
fn empty() -> Self
fn length(&self) -> usize
Sourcefn split_at(self, index: usize) -> Option<[Self; 2]>
fn split_at(self, index: usize) -> Option<[Self; 2]>
Split all of self
into two disjoint contiguous subbuffers of lengths index
and `length
- index` respectively.
Returns None if and only if index > length
.
Sourcefn copy_from_slice_exact(self, src: &[u8]) -> Result<()>
fn copy_from_slice_exact(self, src: &[u8]) -> Result<()>
Copy from src
, lengths must match exactly.
Allowed to overwrite subsequent buffer space, for performance reasons. Can be changed in the future if too restrictive.
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.