pub trait Pod:
FromBytes
+ IntoBytes
+ KnownLayout
+ Immutable
+ Copy {
// Provided methods
fn from_bytes(bytes: &[u8]) -> Self { ... }
fn from_first_bytes(bytes: &[u8]) -> Self { ... }
}Expand description
A trait for plain old data (POD).
A POD type T: Pod can be safely converted to and from an arbitrary byte
sequence of length size_of::<T>().
For example, primitive types such as u8 and i16 are POD types.
See the crate-level documentation for design notes and usage guidance.
Provided Methods§
Sourcefn from_bytes(bytes: &[u8]) -> Self
fn from_bytes(bytes: &[u8]) -> Self
Sourcefn from_first_bytes(bytes: &[u8]) -> Self
fn from_first_bytes(bytes: &[u8]) -> Self
Creates a new instance by copying the first size_of::<Self>() bytes from bytes.
This is useful when bytes contains a larger buffer (e.g., a header followed by
payload) and you only want to interpret the prefix as Self.
§Panics
Panics if bytes.len() < size_of::<Self>().
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.