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
impl Pod for ()
impl Pod for f32
impl Pod for f64
impl Pod for i8
impl Pod for u8
impl Pod for i16
impl Pod for u16
impl Pod for i32
impl Pod for u32
impl Pod for i64
impl Pod for u64
impl Pod for isize
impl Pod for usize
impl<T> Pod for *const T
impl<T> Pod for *mut T
impl<T: Pod> Pod for (T,)
impl<T: Pod> Pod for [T; 0x00]
impl<T: Pod> Pod for [T; 0x01]
impl<T: Pod> Pod for [T; 0x02]
impl<T: Pod> Pod for [T; 0x03]
impl<T: Pod> Pod for [T; 0x04]
impl<T: Pod> Pod for [T; 0x05]
impl<T: Pod> Pod for [T; 0x06]
impl<T: Pod> Pod for [T; 0x07]
impl<T: Pod> Pod for [T; 0x08]
impl<T: Pod> Pod for [T; 0x09]
impl<T: Pod> Pod for [T; 0x0a]
impl<T: Pod> Pod for [T; 0x0b]
impl<T: Pod> Pod for [T; 0x0c]
impl<T: Pod> Pod for [T; 0x0d]
impl<T: Pod> Pod for [T; 0x0e]
impl<T: Pod> Pod for [T; 0x0f]
impl<T: Pod> Pod for [T; 0x10]
impl<T: Pod> Pod for [T; 0x11]
impl<T: Pod> Pod for [T; 0x12]
impl<T: Pod> Pod for [T; 0x13]
impl<T: Pod> Pod for [T; 0x14]
impl<T: Pod> Pod for [T; 0x15]
impl<T: Pod> Pod for [T; 0x16]
impl<T: Pod> Pod for [T; 0x17]
impl<T: Pod> Pod for [T; 0x18]
impl<T: Pod> Pod for [T; 0x19]
impl<T: Pod> Pod for [T; 0x1a]
impl<T: Pod> Pod for [T; 0x1b]
impl<T: Pod> Pod for [T; 0x1c]
impl<T: Pod> Pod for [T; 0x1d]
impl<T: Pod> Pod for [T; 0x1e]
impl<T: Pod> Pod for [T; 0x1f]
impl<T: Pod> Pod for [T; 0x20]
impl<T: Pod> Pod for [T; 0x21]
impl<T: Pod> Pod for [T; 0x22]
impl<T: Pod> Pod for [T; 0x23]
impl<T: Pod> Pod for [T; 0x24]
impl<T: Pod> Pod for [T; 0x25]
impl<T: Pod> Pod for [T; 0x26]
impl<T: Pod> Pod for [T; 0x27]
impl<T: Pod> Pod for [T; 0x28]
impl<T: Pod> Pod for [T; 0x29]
impl<T: Pod> Pod for [T; 0x2a]
impl<T: Pod> Pod for [T; 0x2b]
impl<T: Pod> Pod for [T; 0x2c]
impl<T: Pod> Pod for [T; 0x2d]
impl<T: Pod> Pod for [T; 0x2e]
impl<T: Pod> Pod for [T; 0x2f]
impl<T: Pod> Pod for [T; 0x30]
impl<T: Pod> Pod for [T; 0x31]
impl<T: Pod> Pod for [T; 0x32]
impl<T: Pod> Pod for [T; 0x33]
impl<T: Pod> Pod for [T; 0x34]
impl<T: Pod> Pod for [T; 0x35]
impl<T: Pod> Pod for [T; 0x36]
impl<T: Pod> Pod for [T; 0x37]
impl<T: Pod> Pod for [T; 0x38]
impl<T: Pod> Pod for [T; 0x39]
impl<T: Pod> Pod for [T; 0x3a]
impl<T: Pod> Pod for [T; 0x3b]
impl<T: Pod> Pod for [T; 0x3c]
impl<T: Pod> Pod for [T; 0x3d]
impl<T: Pod> Pod for [T; 0x3e]
impl<T: Pod> Pod for [T; 0x3f]
impl<T: Pod> Pod for [T; 0x40]
impl<B, T: EndianConvert> Pod for EndianPrimitive<B, T>