Trait pod::PodExt [] [src]

pub trait PodExt: Sized {
    fn as_slice<'a>(&'a self) -> &'a [u8] { ... }
    fn mut_slice<'a>(&'a mut self) -> &'a mut [u8] { ... }
    fn from_slice<'a>(slice: &'a [u8]) -> &'a Self { ... }
    fn from_mut_slice<'a>(slice: &'a mut [u8]) -> &'a mut Self { ... }
    fn from_vec(vec: Vec<u8>) -> Box<Self> { ... }
    fn from_box(slice: Box<[u8]>) -> Box<Self> { ... }
}

Helper methods for converting Plain Old Data types to/from byte slices and vectors

Provided Methods

fn as_slice<'a>(&'a self) -> &'a [u8]

Borrows the POD as a byte slice

fn mut_slice<'a>(&'a mut self) -> &'a mut [u8]

Borrows the POD as a mutable byte slice

fn from_slice<'a>(slice: &'a [u8]) -> &'a Self

Borrows a new instance of the POD from a byte slice

Panics

Panics if slice.len() is not the same as the type's size

fn from_mut_slice<'a>(slice: &'a mut [u8]) -> &'a mut Self

Borrows a mutable instance of the POD from a mutable byte slice

Panics

Panics if slice.len() is not the same as the type's size

fn from_vec(vec: Vec<u8>) -> Box<Self>

Converts a byte vector to a boxed instance of the POD type

Panics

Panics if vec.len() is not the same as the type's size

fn from_box(slice: Box<[u8]>) -> Box<Self>

Converts a boxed slice to a boxed instance of the POD type

Panics

Panics if slice.len() is not the same as the type's size

Implementors