Trait Pod

pub unsafe trait Pod: Sized + Copy {
    // Provided methods
    fn new_zeroed() -> Self { ... }
    fn new_uninit() -> Self { ... }
    fn from_bytes(bytes: &[u8]) -> Self { ... }
    fn as_bytes(&self) -> &[u8] { ... }
    fn as_bytes_mut(&mut self) -> &mut [u8] { ... }
}
Expand description

A marker trait for plain old data (POD).

A POD type T:Pod supports converting to and from arbitrary mem::size_of::<T>() bytes safely. For example, simple primitive types like u8 and i16 are POD types. But perhaps surprisingly, bool is not POD because Rust compiler makes implicit assumption that a byte of bool has a value of either 0 or 1. Interpreting a byte of value 3 has a bool value has undefined behavior.

§Safety

Marking a non-POD type as POD may cause undefined behaviors.

Provided Methods§

fn new_zeroed() -> Self

Creates a new instance of Pod type that is filled with zeroes.

fn new_uninit() -> Self

Creates a new instance of Pod type with uninitialized content.

fn from_bytes(bytes: &[u8]) -> Self

Creates a new instance from the given bytes.

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

As a slice of bytes.

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

As a mutable slice of bytes.

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§

§

impl Pod for i8

§

impl Pod for i16

§

impl Pod for i32

§

impl Pod for i64

§

impl Pod for i128

§

impl Pod for isize

§

impl Pod for u8

§

impl Pod for u16

§

impl Pod for u32

§

impl Pod for u64

§

impl Pod for u128

§

impl Pod for usize

§

impl<T, const N: usize> Pod for [T; N]
where T: Pod,

Implementors§

Source§

impl Pod for ContextEntry
where u128: Pod,

Source§

impl Pod for RootEntry
where u128: Pod,

Source§

impl Pod for ostd::arch::iommu::dma_remapping::second_stage::PageTableEntry
where u64: Pod,

Source§

impl Pod for ostd::arch::iommu::dma_remapping::second_stage::PageTableFlags
where u64: Pod,

Source§

impl Pod for AnddHeader
where u16: Pod, [u8; 3]: Pod, u8: Pod,

Source§

impl Pod for AtsrHeader
where u16: Pod, u8: Pod,

Source§

impl Pod for DeviceScopeHeader
where u8: Pod,

Source§

impl Pod for DrhdHeader
where u16: Pod, u8: Pod, u64: Pod,

Source§

impl Pod for Rhsa
where u16: Pod, u32: Pod, u64: Pod,

Source§

impl Pod for RmrrHeader
where u16: Pod, u64: Pod,

Source§

impl Pod for SatcHeader
where u16: Pod, u8: Pod,

Source§

impl Pod for SidpHeader
where u16: Pod,

Source§

impl Pod for ostd::arch::mm::PageTableEntry
where usize: Pod,

Source§

impl Pod for ostd::arch::mm::PageTableFlags
where usize: Pod,