Trait Pod

Source
pub unsafe trait Pod: Sized {
Show 52 methods // Provided methods 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> { ... }
}
Expand description

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

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

Provided Methods§

Source

unsafe fn uninitialized() -> Self

Generates a new uninitialized instance of a POD type.

Source

fn zeroed() -> Self

Creates a new zeroed instance of a POD type.

Source

fn copy(&self) -> Self

Creates a copy of this POD instance

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Converts a POD slice into another type.

Returns None if T is larger.

Source

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.

Source

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.

Source

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.

Source

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

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

Source

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

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

Source

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()

Source

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

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

Source

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()

Source

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

Creates a POD reference with the inverse of map()

Source

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

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

Source

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

Creates a POD reference with the inverse of merge()

Source

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

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

Source

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

Borrows the POD as a byte slice

Source

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

Borrows the POD as a mutable byte slice

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Converts a boxed POD to a boxed slice

Source

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

Converts a boxed POD to a byte vector

Source

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

Source

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

Source

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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Pod for f32

Source§

impl Pod for f64

Source§

impl Pod for i8

Source§

impl Pod for i16

Source§

impl Pod for i32

Source§

impl Pod for i64

Source§

impl Pod for isize

Source§

impl Pod for u8

Source§

impl Pod for u16

Source§

impl Pod for u32

Source§

impl Pod for u64

Source§

impl Pod for ()

Source§

impl Pod for usize

Source§

impl<T> Pod for *const T

Source§

impl<T> Pod for *mut T

Source§

impl<T: Pod> Pod for [T; 0]

Source§

impl<T: Pod> Pod for [T; 1]

Source§

impl<T: Pod> Pod for [T; 2]

Source§

impl<T: Pod> Pod for [T; 3]

Source§

impl<T: Pod> Pod for [T; 4]

Source§

impl<T: Pod> Pod for [T; 5]

Source§

impl<T: Pod> Pod for [T; 6]

Source§

impl<T: Pod> Pod for [T; 7]

Source§

impl<T: Pod> Pod for [T; 8]

Source§

impl<T: Pod> Pod for [T; 9]

Source§

impl<T: Pod> Pod for [T; 10]

Source§

impl<T: Pod> Pod for [T; 11]

Source§

impl<T: Pod> Pod for [T; 12]

Source§

impl<T: Pod> Pod for [T; 13]

Source§

impl<T: Pod> Pod for [T; 14]

Source§

impl<T: Pod> Pod for [T; 15]

Source§

impl<T: Pod> Pod for [T; 16]

Source§

impl<T: Pod> Pod for [T; 17]

Source§

impl<T: Pod> Pod for [T; 18]

Source§

impl<T: Pod> Pod for [T; 19]

Source§

impl<T: Pod> Pod for [T; 20]

Source§

impl<T: Pod> Pod for [T; 21]

Source§

impl<T: Pod> Pod for [T; 22]

Source§

impl<T: Pod> Pod for [T; 23]

Source§

impl<T: Pod> Pod for [T; 24]

Source§

impl<T: Pod> Pod for [T; 25]

Source§

impl<T: Pod> Pod for [T; 26]

Source§

impl<T: Pod> Pod for [T; 27]

Source§

impl<T: Pod> Pod for [T; 28]

Source§

impl<T: Pod> Pod for [T; 29]

Source§

impl<T: Pod> Pod for [T; 30]

Source§

impl<T: Pod> Pod for [T; 31]

Source§

impl<T: Pod> Pod for [T; 32]

Source§

impl<T: Pod> Pod for [T; 33]

Source§

impl<T: Pod> Pod for [T; 34]

Source§

impl<T: Pod> Pod for [T; 35]

Source§

impl<T: Pod> Pod for [T; 36]

Source§

impl<T: Pod> Pod for [T; 37]

Source§

impl<T: Pod> Pod for [T; 38]

Source§

impl<T: Pod> Pod for [T; 39]

Source§

impl<T: Pod> Pod for [T; 40]

Source§

impl<T: Pod> Pod for [T; 41]

Source§

impl<T: Pod> Pod for [T; 42]

Source§

impl<T: Pod> Pod for [T; 43]

Source§

impl<T: Pod> Pod for [T; 44]

Source§

impl<T: Pod> Pod for [T; 45]

Source§

impl<T: Pod> Pod for [T; 46]

Source§

impl<T: Pod> Pod for [T; 47]

Source§

impl<T: Pod> Pod for [T; 48]

Source§

impl<T: Pod> Pod for [T; 49]

Source§

impl<T: Pod> Pod for [T; 50]

Source§

impl<T: Pod> Pod for [T; 51]

Source§

impl<T: Pod> Pod for [T; 52]

Source§

impl<T: Pod> Pod for [T; 53]

Source§

impl<T: Pod> Pod for [T; 54]

Source§

impl<T: Pod> Pod for [T; 55]

Source§

impl<T: Pod> Pod for [T; 56]

Source§

impl<T: Pod> Pod for [T; 57]

Source§

impl<T: Pod> Pod for [T; 58]

Source§

impl<T: Pod> Pod for [T; 59]

Source§

impl<T: Pod> Pod for [T; 60]

Source§

impl<T: Pod> Pod for [T; 61]

Source§

impl<T: Pod> Pod for [T; 62]

Source§

impl<T: Pod> Pod for [T; 63]

Source§

impl<T: Pod> Pod for [T; 64]

Source§

impl<T: Pod> Pod for [T; 256]

Source§

impl<T: Pod> Pod for [T; 512]

Source§

impl<T: Pod> Pod for [T; 768]

Source§

impl<T: Pod> Pod for [T; 1024]

Source§

impl<T: Pod> Pod for [T; 1280]

Source§

impl<T: Pod> Pod for [T; 1536]

Source§

impl<T: Pod> Pod for [T; 1792]

Source§

impl<T: Pod> Pod for [T; 2048]

Source§

impl<T: Pod> Pod for [T; 2304]

Source§

impl<T: Pod> Pod for [T; 2560]

Source§

impl<T: Pod> Pod for [T; 2816]

Source§

impl<T: Pod> Pod for [T; 3072]

Source§

impl<T: Pod> Pod for [T; 3328]

Source§

impl<T: Pod> Pod for [T; 3584]

Source§

impl<T: Pod> Pod for [T; 3840]

Source§

impl<T: Pod> Pod for [T; 4096]

Source§

impl<T: Pod> Pod for (T,)

Implementors§