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
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; 0]
impl<T: Pod> Pod for [T; 1]
impl<T: Pod> Pod for [T; 2]
impl<T: Pod> Pod for [T; 3]
impl<T: Pod> Pod for [T; 4]
impl<T: Pod> Pod for [T; 5]
impl<T: Pod> Pod for [T; 6]
impl<T: Pod> Pod for [T; 7]
impl<T: Pod> Pod for [T; 8]
impl<T: Pod> Pod for [T; 9]
impl<T: Pod> Pod for [T; 10]
impl<T: Pod> Pod for [T; 11]
impl<T: Pod> Pod for [T; 12]
impl<T: Pod> Pod for [T; 13]
impl<T: Pod> Pod for [T; 14]
impl<T: Pod> Pod for [T; 15]
impl<T: Pod> Pod for [T; 16]
impl<T: Pod> Pod for [T; 17]
impl<T: Pod> Pod for [T; 18]
impl<T: Pod> Pod for [T; 19]
impl<T: Pod> Pod for [T; 20]
impl<T: Pod> Pod for [T; 21]
impl<T: Pod> Pod for [T; 22]
impl<T: Pod> Pod for [T; 23]
impl<T: Pod> Pod for [T; 24]
impl<T: Pod> Pod for [T; 25]
impl<T: Pod> Pod for [T; 26]
impl<T: Pod> Pod for [T; 27]
impl<T: Pod> Pod for [T; 28]
impl<T: Pod> Pod for [T; 29]
impl<T: Pod> Pod for [T; 30]
impl<T: Pod> Pod for [T; 31]
impl<T: Pod> Pod for [T; 32]
impl<T: Pod> Pod for [T; 33]
impl<T: Pod> Pod for [T; 34]
impl<T: Pod> Pod for [T; 35]
impl<T: Pod> Pod for [T; 36]
impl<T: Pod> Pod for [T; 37]
impl<T: Pod> Pod for [T; 38]
impl<T: Pod> Pod for [T; 39]
impl<T: Pod> Pod for [T; 40]
impl<T: Pod> Pod for [T; 41]
impl<T: Pod> Pod for [T; 42]
impl<T: Pod> Pod for [T; 43]
impl<T: Pod> Pod for [T; 44]
impl<T: Pod> Pod for [T; 45]
impl<T: Pod> Pod for [T; 46]
impl<T: Pod> Pod for [T; 47]
impl<T: Pod> Pod for [T; 48]
impl<T: Pod> Pod for [T; 49]
impl<T: Pod> Pod for [T; 50]
impl<T: Pod> Pod for [T; 51]
impl<T: Pod> Pod for [T; 52]
impl<T: Pod> Pod for [T; 53]
impl<T: Pod> Pod for [T; 54]
impl<T: Pod> Pod for [T; 55]
impl<T: Pod> Pod for [T; 56]
impl<T: Pod> Pod for [T; 57]
impl<T: Pod> Pod for [T; 58]
impl<T: Pod> Pod for [T; 59]
impl<T: Pod> Pod for [T; 60]
impl<T: Pod> Pod for [T; 61]
impl<T: Pod> Pod for [T; 62]
impl<T: Pod> Pod for [T; 63]
impl<T: Pod> Pod for [T; 64]
impl<T: Pod> Pod for [T; 256]
impl<T: Pod> Pod for [T; 512]
impl<T: Pod> Pod for [T; 768]
impl<T: Pod> Pod for [T; 1024]
impl<T: Pod> Pod for [T; 1280]
impl<T: Pod> Pod for [T; 1536]
impl<T: Pod> Pod for [T; 1792]
impl<T: Pod> Pod for [T; 2048]
impl<T: Pod> Pod for [T; 2304]
impl<T: Pod> Pod for [T; 2560]
impl<T: Pod> Pod for [T; 2816]
impl<T: Pod> Pod for [T; 3072]
impl<T: Pod> Pod for [T; 3328]
impl<T: Pod> Pod for [T; 3584]
impl<T: Pod> Pod for [T; 3840]
impl<T: Pod> Pod for [T; 4096]