Crate pod [] [src]

Provides traits that assist with I/O and byte slice conversions involving Plain Old Data.

Safety

The nue-macros crate can be used for safe automagic derives.

Example

use pod::{Pod, PodExt, Le, Be};

unsafe impl Pod for Data { }

#[repr(packed)]
struct Data(u8, Le<u16>, Be<u32>);

let data = Data(1, Le::new(0x2055), Be::new(0xdeadbeef));

let cmp = &[
    0x01,
    0x55, 0x20,
    0xde, 0xad, 0xbe, 0xef,
];

assert_eq!(cmp, data.as_slice());

Reexports

pub use endian::{Le, Be, Native};
pub use code::{Encode, Decode};

Modules

code

I/O traits for POD and other types.

endian

Containers for primitives

packed

Traits

Pod

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

PodExt

Helper methods for converting POD types to/from byte slices and vectors