pub trait Buffer {
// Required methods
fn try_cast<T: MinimallyAligned>(
&self,
offset: u32,
) -> Result<&T, CastError>;
fn try_cast_slice<T: MinimallyAligned>(
&self,
offset: u32,
len: u32,
) -> Result<&[T], CastError>;
fn cast<T: MinimallyAligned>(&self, offset: u32) -> &T;
fn cast_slice<T: MinimallyAligned>(&self, offset: u32, len: u32) -> &[T];
}
Expand description
Additional methods on byte slices
Required Methods§
Sourcefn try_cast_slice<T: MinimallyAligned>(
&self,
offset: u32,
len: u32,
) -> Result<&[T], CastError>
fn try_cast_slice<T: MinimallyAligned>( &self, offset: u32, len: u32, ) -> Result<&[T], CastError>
Try to cast to T
Sourcefn cast<T: MinimallyAligned>(&self, offset: u32) -> &T
fn cast<T: MinimallyAligned>(&self, offset: u32) -> &T
Cast to T
Sourcefn cast_slice<T: MinimallyAligned>(&self, offset: u32, len: u32) -> &[T]
fn cast_slice<T: MinimallyAligned>(&self, offset: u32, len: u32) -> &[T]
Cast to slice of T
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.
Implementations on Foreign Types§
Source§impl Buffer for [u8]
impl Buffer for [u8]
Source§fn try_cast<T: MinimallyAligned>(&self, offset: u32) -> Result<&T, CastError>
fn try_cast<T: MinimallyAligned>(&self, offset: u32) -> Result<&T, CastError>
Try to cast to T
Source§fn try_cast_slice<T: MinimallyAligned>(
&self,
offset: u32,
len: u32,
) -> Result<&[T], CastError>
fn try_cast_slice<T: MinimallyAligned>( &self, offset: u32, len: u32, ) -> Result<&[T], CastError>
Try to cast to T
Source§fn cast_slice<T: MinimallyAligned>(&self, offset: u32, len: u32) -> &[T]
fn cast_slice<T: MinimallyAligned>(&self, offset: u32, len: u32) -> &[T]
Cast to slice of T