pub trait U32Packer {
// Required methods
fn pack_u32(first: u32, second: u32) -> Self;
fn first_u32(&self) -> u32;
fn second_u32(&self) -> u32;
// Provided method
fn unpack_u32(&self) -> (u32, u32) { ... }
}Expand description
Trait for packing and unpacking two u32 values into a single value.
Required Methods§
Sourcefn pack_u32(first: u32, second: u32) -> Self
fn pack_u32(first: u32, second: u32) -> Self
Packs two u32 values into a single value of the implementing type.
§Example
use num_packer::U32Packer;
let packed = u64::pack_u32(200, 55);
assert_eq!(packed, (200u64 << 32) + 55);Sourcefn first_u32(&self) -> u32
fn first_u32(&self) -> u32
Gets the first u32 value from the packed representation.
§Example
use num_packer::U32Packer;
let packed = u64::pack_u32(200, 55);
assert_eq!(packed.first_u32(), 200);Sourcefn second_u32(&self) -> u32
fn second_u32(&self) -> u32
Gets the second u32 value from the packed representation.
§Example
use num_packer::U32Packer;
let packed = u64::pack_u32(200, 55);
assert_eq!(packed.second_u32(), 55);
`Provided Methods§
Sourcefn unpack_u32(&self) -> (u32, u32)
fn unpack_u32(&self) -> (u32, u32)
Unpacks the single value back into two u32 values.
§Example
use num_packer::U32Packer;
let packed = u64::pack_u32(200, 55);
let (first, second) = packed.unpack_u32();
assert_eq!((first, second), (200, 55));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.