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§

source

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>

Try to cast to T

source

fn cast<T: MinimallyAligned>(&self, offset: u32) -> &T

Cast to T

source

fn cast_slice<T: MinimallyAligned>(&self, offset: u32, len: u32) -> &[T]

Cast to slice of T

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Buffer for [u8]

source§

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>

Try to cast to T

source§

fn cast<T: MinimallyAligned>(&self, offset: u32) -> &T

Cast to T

source§

fn cast_slice<T: MinimallyAligned>(&self, offset: u32, len: u32) -> &[T]

Cast to slice of T

Implementors§