Skip to main content

PackedItem

Trait PackedItem 

Source
pub trait PackedItem:
    IntoBytes
    + Immutable
    + Unaligned {
    // Required method
    unsafe fn from_bytes(bytes: &[u8]) -> &Self;
}
Expand description

A trait for types that can be packed into a single contiguous buffer of bytes.

Required Methods§

Source

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

Reconstructs the item from a byte slice.

§Safety

The caller must guarantee that the slice contains data that is byte-identical to a slice returned by IntoBytes::as_bytes for a valid instance of this type.

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 PackedItem for str

Source§

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

Source§

impl PackedItem for [u8]

Source§

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

Implementors§