Skip to main content

Pod

Trait Pod 

pub unsafe trait Pod: Sized + Copy {
    // Provided methods
    fn new_zeroed() -> Self { ... }
    fn new_uninit() -> Self { ... }
    fn as_bytes(&self) -> &[u8]  { ... }
    fn as_bytes_mut(&mut self) -> &mut [u8]  { ... }
    fn as_array_ptr_bytes<const N: usize>(
        &self,
    ) -> (ArrayPtr<u8, N>, Tracked<&PointsTo<u8, N>>) { ... }
}
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 as_bytes(&self) -> &[u8]

As an immutable slice of bytes.

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

As a mutable slice of bytes.

fn as_array_ptr_bytes<const N: usize>( &self, ) -> (ArrayPtr<u8, N>, Tracked<&PointsTo<u8, N>>)

As a slice of bytes via an [ArrayPtr] (with a tracked permission).

This is the verus-flavored variant; the raw &[u8] view is Self::as_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§