Trait pod::Pod [] [src]

pub unsafe trait Pod: Sized {
    unsafe fn uninitialized() -> Self { ... }
    fn zeroed() -> Self { ... }
    fn copy(&self) -> Self { ... }
    fn map<T: Pod>(&self) -> Option<&T> { ... }
    fn map_mut<T: Pod>(&mut self) -> Option<&mut T> { ... }
    fn map_copy<T: Pod>(&self) -> Option<T> { ... }
    fn try_map<T: Pod>(&self) -> Option<&T> { ... }
    fn try_map_mut<T: Pod>(&mut self) -> Option<&mut T> { ... }
    fn try_map_copy<T: Pod>(&self) -> Option<T> { ... }
    fn map_box<T: Pod>(self: Box<Self>) -> Result<Box<T>, Box<Self>> { ... }
    fn split<T: Pod>(&self) -> Option<&[T]> { ... }
    fn split_mut<T: Pod>(&mut self) -> Option<&mut [T]> { ... }
    fn try_split<T: Pod>(&self) -> &[T] { ... }
    fn try_split_mut<T: Pod>(&mut self) -> &mut [T] { ... }
    fn split_box<T: Pod>(self: Box<Self>) -> Result<Box<[T]>, Box<Self>> { ... }
    fn split_vec<T: Pod>(self: Box<Self>) -> Result<Vec<T>, Box<Self>> { ... }
    fn map_slice<T: Pod>(s: &[Self]) -> Option<&[T]> { ... }
    fn map_slice_mut<T: Pod>(s: &mut [Self]) -> Option<&mut [T]> { ... }
    fn try_map_slice<T: Pod>(s: &[Self]) -> &[T] { ... }
    fn try_map_slice_mut<T: Pod>(s: &mut [Self]) -> &mut [T] { ... }
    fn map_slice_box<T: Pod>(s: Box<[Self]>) -> Result<Box<[T]>, Box<[Self]>> { ... }
    fn map_slice_vec<T: Pod>(s: Vec<Self>) -> Result<Vec<T>, Vec<Self>> { ... }
    fn merge<T: Pod>(s: &[Self]) -> Option<&T> { ... }
    fn merge_mut<T: Pod>(s: &mut [Self]) -> Option<&mut T> { ... }
    fn merge_copy<T: Pod>(s: &[Self]) -> Option<T> { ... }
    fn try_merge<T: Pod>(s: &[Self]) -> Option<&T> { ... }
    fn try_merge_mut<T: Pod>(s: &mut [Self]) -> Option<&mut T> { ... }
    fn try_merge_copy<T: Pod>(s: &[Self]) -> Option<T> { ... }
    fn merge_box<T: Pod>(s: Box<[Self]>) -> Result<Box<T>, Box<[Self]>> { ... }
    fn merge_vec<T: Pod>(s: Vec<Self>) -> Result<Box<T>, Vec<Self>> { ... }
    unsafe fn from_ptr<T>(source: *const T) -> Self { ... }
    fn from_ref<T: Pod>(p: &T) -> Option<Self> { ... }
    fn from_slice<T: Pod>(p: &[T]) -> Option<Self> { ... }
    fn from_boxed_slice<T: Pod>(p: Box<[T]>) -> Result<Box<Self>, Box<[T]>> { ... }
    fn from_vec<T: Pod>(p: Vec<T>) -> Result<Box<Self>, Vec<T>> { ... }
    fn slice_from_boxed_slice<T: Pod>(p: Box<[T]>) -> Result<Box<[Self]>, Box<[T]>> { ... }
    fn ref_from<T: Pod>(p: &T) -> Option<&Self> { ... }
    fn ref_from_mut<T: Pod>(p: &mut T) -> Option<&mut Self> { ... }
    fn ref_from_slice<T: Pod>(p: &[T]) -> Option<&Self> { ... }
    fn ref_from_slice_mut<T: Pod>(p: &mut [T]) -> Option<&mut Self> { ... }
    fn as_bytes(&self) -> &[u8] { ... }
    fn as_bytes_mut(&mut self) -> &mut [u8] { ... }
    fn from_bytes(p: &[u8]) -> Option<Self> { ... }
    fn ref_from_bytes(p: &[u8]) -> Option<&Self> { ... }
    fn ref_from_bytes_mut(p: &mut [u8]) -> Option<&mut Self> { ... }
    fn from_byte_slice(p: Box<[u8]>) -> Result<Box<Self>, Box<[u8]>> { ... }
    fn from_byte_vec(p: Vec<u8>) -> Result<Box<Self>, Vec<u8>> { ... }
    fn into_byte_slice(self: Box<Self>) -> Box<[u8]> { ... }
    fn into_byte_vec(self: Box<Self>) -> Vec<u8> { ... }
    fn as_aligned_mut<T: Pod + Aligned<Unaligned=Self>>(&mut self) -> Option<&mut T> where Self: Copy + Unaligned { ... }
    fn from_unaligned_mut<T: Copy + Unaligned>(s: &mut T) -> Option<&mut Self> where Self: Aligned<Unaligned=T> { ... }
    fn from_unaligned<T: Copy + Unaligned>(s: T) -> Self where Self: Aligned<Unaligned=T> { ... }
}

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

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

Provided Methods

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 copy(&self) -> Self

Creates a copy of this POD instance

fn map<T: Pod>(&self) -> Option<&T>

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

Returns None if the two types are misaligned or not the same size.

fn map_mut<T: Pod>(&mut self) -> Option<&mut T>

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

Returns None if the two types are misaligned or not the same size.

fn map_copy<T: Pod>(&self) -> Option<T>

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

Returns None if the two types are not the same size.

fn try_map<T: Pod>(&self) -> Option<&T>

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

Returns None if the two types are misaligned or T is larger.

fn try_map_mut<T: Pod>(&mut self) -> Option<&mut T>

Converts a mutable POD reference from one to another type of the same or lesser size.

Returns None if the two types are misaligned or T is larger.

fn try_map_copy<T: Pod>(&self) -> Option<T>

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

Returns None if T is larger.

fn map_box<T: Pod>(self: Box<Self>) -> Result<Box<T>, Box<Self>>

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

Fails if the two types are misaligned or not the same size.

fn split<T: Pod>(&self) -> Option<&[T]>

Converts a POD reference into a slice of another type.

Returns None if the types are misaligned or do not fit perfectly.

fn split_mut<T: Pod>(&mut self) -> Option<&mut [T]>

Converts a mutable POD reference into a slice of another type.

Returns None if the types are misaligned or do not fit perfectly.

fn try_split<T: Pod>(&self) -> &[T]

Converts a POD reference into a slice of another type.

Returns an empty slice if the types are misaligned.

fn try_split_mut<T: Pod>(&mut self) -> &mut [T]

Converts a mutable POD reference into a slice of another type.

Returns an empty slice if the types are misaligned.

fn split_box<T: Pod>(self: Box<Self>) -> Result<Box<[T]>, Box<Self>>

Converts a boxed POD object into a boxed slice of another type.

Fails if the types are misaligned or do not fit perfectly.

fn split_vec<T: Pod>(self: Box<Self>) -> Result<Vec<T>, Box<Self>>

Converts a boxed POD object into a vector of another type.

Fails if the types are misaligned or do not fit perfectly.

fn map_slice<T: Pod>(s: &[Self]) -> Option<&[T]>

Maps a POD slice from one type to another.

Returns None if the slice is misaligned or the output type does not perfectly fit.

fn map_slice_mut<T: Pod>(s: &mut [Self]) -> Option<&mut [T]>

Maps a mutable POD slice from one type to another.

Returns None if the slice is misaligned or the output type does not perfectly fit.

fn try_map_slice<T: Pod>(s: &[Self]) -> &[T]

Maps a POD slice from one type to another.

Returns None if the slice is misaligned.

fn try_map_slice_mut<T: Pod>(s: &mut [Self]) -> &mut [T]

Maps a mutable POD slice from one type to another.

Returns None if the slice is misaligned.

fn map_slice_box<T: Pod>(s: Box<[Self]>) -> Result<Box<[T]>, Box<[Self]>>

Maps a boxed POD slice from one type to another.

Fails if the slice is misaligned or does not perfectly fit.

fn map_slice_vec<T: Pod>(s: Vec<Self>) -> Result<Vec<T>, Vec<Self>>

Maps a POD vector from one type to another.

Fails if the slice is misaligned or does not perfectly fit.

fn merge<T: Pod>(s: &[Self]) -> Option<&T>

Converts a POD slice into another type.

Returns None if the types are misaligned or not the same size.

fn merge_mut<T: Pod>(s: &mut [Self]) -> Option<&mut T>

Converts a mutable POD slice into another type.

Returns None if the types are misaligned or not the same size.

fn merge_copy<T: Pod>(s: &[Self]) -> Option<T>

Converts a POD slice into another type.

Returns None if the types are not the same size.

fn try_merge<T: Pod>(s: &[Self]) -> Option<&T>

Converts a POD slice into another type.

Returns None if the types are misaligned or T is larger.

fn try_merge_mut<T: Pod>(s: &mut [Self]) -> Option<&mut T>

Converts a mutable POD slice into another type.

Returns None if the types are misaligned or T is larger.

fn try_merge_copy<T: Pod>(s: &[Self]) -> Option<T>

Converts a POD slice into another type.

Returns None if T is larger.

fn merge_box<T: Pod>(s: Box<[Self]>) -> Result<Box<T>, Box<[Self]>>

Converts a boxed POD slice into another boxed type.

Fails if the types are misaligned or not the same size.

fn merge_vec<T: Pod>(s: Vec<Self>) -> Result<Box<T>, Vec<Self>>

Converts a POD vector into another boxed type.

Fails if the types are misaligned or not the same size.

unsafe fn from_ptr<T>(source: *const T) -> Self

Creates a new POD instance from an unaligned pointer.

This is an unsafe operation because the pointer is not validated in any way.

fn from_ref<T: Pod>(p: &T) -> Option<Self>

Creates a new POD instance with the inverse of map_copy()

fn from_slice<T: Pod>(p: &[T]) -> Option<Self>

Creates a new POD instance with the inverse of merge_copy()

fn from_boxed_slice<T: Pod>(p: Box<[T]>) -> Result<Box<Self>, Box<[T]>>

Creates a new POD instance with the inverse of merge_box()

fn from_vec<T: Pod>(p: Vec<T>) -> Result<Box<Self>, Vec<T>>

Creates a new POD instance with the inverse of merge_vec()

fn slice_from_boxed_slice<T: Pod>(p: Box<[T]>) -> Result<Box<[Self]>, Box<[T]>>

Creates a new POD instance with the inverse of map_slice_box()

fn ref_from<T: Pod>(p: &T) -> Option<&Self>

Creates a POD reference with the inverse of map()

fn ref_from_mut<T: Pod>(p: &mut T) -> Option<&mut Self>

Creates a mutable POD reference with the inverse of map_mut()

fn ref_from_slice<T: Pod>(p: &[T]) -> Option<&Self>

Creates a POD reference with the inverse of merge()

fn ref_from_slice_mut<T: Pod>(p: &mut [T]) -> Option<&mut Self>

Creates a mutable POD reference with the inverse of merge_mut()

fn as_bytes(&self) -> &[u8]

Borrows the POD as a byte slice

fn as_bytes_mut(&mut self) -> &mut [u8]

Borrows the POD as a mutable byte slice

fn from_bytes(p: &[u8]) -> Option<Self>

Safely creates a POD value from a potentially unaligned slice

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

fn ref_from_bytes(p: &[u8]) -> Option<&Self>

Borrows a new instance of the POD from a byte slice

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

fn ref_from_bytes_mut(p: &mut [u8]) -> Option<&mut Self>

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

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

fn from_byte_slice(p: Box<[u8]>) -> Result<Box<Self>, Box<[u8]>>

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

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

fn from_byte_vec(p: Vec<u8>) -> Result<Box<Self>, Vec<u8>>

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

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

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

Converts a boxed POD to a boxed slice

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

Converts a boxed POD to a byte vector

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

Safely borrows the aligned value mutably

See also: Aligned::from_unaligned_mut

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

Safely borrows the unaligned value mutably

See also: Aligned::from_unaligned_mut

fn from_unaligned<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

Implementors