pub trait FromBytes<const T: usize> {
// Required methods
fn from_le_bytes(bytes: [u8; T]) -> Self;
fn from_be_bytes(bytes: [u8; T]) -> Self;
}
Expand description
Defines a type can be converted from a byte array.
use num_bytes::FromBytes;
let a = [8,0,0,0];
let b = u32::from_le_bytes(a);
assert_eq!(b,8);
Required Methods§
fn from_le_bytes(bytes: [u8; T]) -> Self
fn from_be_bytes(bytes: [u8; T]) -> 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.