Trait win_crypto_ng::helpers::FromBytes
source · pub unsafe trait FromBytes {
const MIN_LAYOUT: Layout;
// Provided methods
fn from_bytes(bytes: &[u8]) -> &Self { ... }
fn from_boxed(boxed: Box<[u8]>) -> Box<Self> { ... }
}
Expand description
Marker trait for types that can be safely converted to bytes.
Required Associated Constants§
sourceconst MIN_LAYOUT: Layout
const MIN_LAYOUT: Layout
Specified the minimum layout requirements for the allocation:
- is at least as big as
MIN_LAYOUT.size()
- referenced/pointed data is at least as aligned as
MIN_LAYOUT.align()
For DSTs, final size should be exactly the same as the allocation’s.
Safety
In Rust, it is considered UB for pointers/references/Box<T>
es to
be dangling, unaligned or pointing to invalid value.
The alignment check is done using MIN_LAYOUT
and thus can cause UB if
implemented incorrectly.