Trait rxdp::ByteAligned[][src]

pub trait ByteAligned: Default + Copy {
    fn align(self) -> Vec<u8>;
fn from_aligned(chunk: &[u8]) -> Self; }

Trait used to convert types to/from 8 byte aligned Vec<u8> (required by per-cpu eBPF maps).

Required methods

fn align(self) -> Vec<u8>[src]

Convert a type to a Vec, padded to the next closest 8 byte alignment:

use rxdp::ByteAligned;
assert_eq!(101u32.align(), vec![101, 0, 0, 0, 0, 0, 0, 0]);

fn from_aligned(chunk: &[u8]) -> Self[src]

Convert a 8 byte aligned Vec<u8> to a type:

use rxdp::ByteAligned;
assert_eq!(101u8, u8::from_aligned(&vec![101, 0, 0, 0, 0, 0, 0, 0]))
Loading content...

Implementations on Foreign Types

impl ByteAligned for u8[src]

impl ByteAligned for u16[src]

impl ByteAligned for u32[src]

impl ByteAligned for u64[src]

impl ByteAligned for u128[src]

impl ByteAligned for usize[src]

impl ByteAligned for i8[src]

impl ByteAligned for i16[src]

impl ByteAligned for i32[src]

impl ByteAligned for i64[src]

impl ByteAligned for i128[src]

impl ByteAligned for isize[src]

Loading content...

Implementors

Loading content...