Trait pod::Pod [] [src]

pub unsafe trait Pod: Sized {
    fn mut_aligned<T: Pod + Aligned<Unaligned=Self>>(&mut self) -> Option<&mut T> where Self: Copy + Unaligned { ... }
    fn mut_unaligned<T: Copy + Unaligned>(s: &mut T) -> Option<&mut Self> where Self: Aligned<Unaligned=T> { ... }
    fn aligned<T: Copy + Unaligned>(s: T) -> Self where Self: Aligned<Unaligned=T> { ... }
    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 where Self: Unaligned { ... }
    fn from_mut_slice<'a>(slice: &'a mut [u8]) -> &'a mut Self where Self: Unaligned { ... }
    fn from_vec(vec: Vec<u8>) -> Box<Self> where Self: Unaligned { ... }
    fn from_box(slice: Box<[u8]>) -> Box<Self> where Self: Unaligned { ... }
    fn to_vec(self: Box<Self>) -> Vec<u8> { ... }
    fn to_boxed_slice(self: Box<Self>) -> Box<[u8]> { ... }
    fn map<'a, T: Pod + Unaligned>(&'a self) -> &'a T where Self: Unaligned { ... }
    fn map_mut<'a, T: Pod + Unaligned>(&'a mut self) -> &'a mut T where Self: Unaligned { ... }
    unsafe fn uninitialized() -> Self { ... }
    fn zeroed() -> Self { ... }
    fn map_slice<'a, T: Pod + Unaligned>(s: &'a [Self]) -> &'a [T] where Self: Unaligned { ... }
    fn map_mut_slice<'a, T: Pod + Unaligned>(s: &'a mut [Self]) -> &'a mut [T] where Self: Unaligned { ... }
}

A marker trait indicating that a type is Plain Old Data.

It is unsafe to impl this manually, use #[derive(Pod)] instead.

Provided Methods

fn mut_aligned<T: Pod + Aligned<Unaligned=Self>>(&mut self) -> Option<&mut T> where Self: Copy + Unaligned

Safely borrows the aligned value mutably

See also: Aligned::as_aligned_mut

fn mut_unaligned<T: Copy + Unaligned>(s: &mut T) -> Option<&mut Self> where Self: Aligned<Unaligned=T>

Safely borrows the unaligned value mutably

See also: Aligned::as_unaligned_mut

fn aligned<T: Copy + Unaligned>(s: T) -> Self where Self: Aligned<Unaligned=T>

Safely converts an unaligned value to its aligned equivalent

See also: Aligned::from_unaligned

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 where Self: Unaligned

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 where Self: Unaligned

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> where Self: Unaligned

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> where Self: Unaligned

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

fn to_vec(self: Box<Self>) -> Vec<u8>

Converts a boxed POD to a byte vector

fn to_boxed_slice(self: Box<Self>) -> Box<[u8]>

Converts a boxed POD to a boxed slice

fn map<'a, T: Pod + Unaligned>(&'a self) -> &'a T where Self: Unaligned

Converts a POD type from one to another of the same size.

Panics

Panics if the two types are not the same size

fn map_mut<'a, T: Pod + Unaligned>(&'a mut self) -> &'a mut T where Self: Unaligned

Converts a POD type from one to another of the same size.

Panics

Panics if the two types are not the same size

unsafe fn uninitialized() -> Self

Generates a new uninitialized instance of a POD type.

fn zeroed() -> Self

Creates a new zeroed instance of a POD type.

fn map_slice<'a, T: Pod + Unaligned>(s: &'a [Self]) -> &'a [T] where Self: Unaligned

Maps a POD slice from one type to another

Panics

Will panic if the output type does not perfectly fit into the slice.

fn map_mut_slice<'a, T: Pod + Unaligned>(s: &'a mut [Self]) -> &'a mut [T] where Self: Unaligned

Maps a mutable POD slice from one type to another

Panics

Will panic if the output type does not perfectly fit into the slice.

Implementors