devela::num

Trait PrimitiveJoin

Source
pub trait PrimitiveJoin<T, U, const LEN: usize> {
    // Required methods
    fn from_array_be(values: [U; LEN]) -> T;
    fn from_array_le(values: [U; LEN]) -> T;
    fn from_array_ne(values: [U; LEN]) -> T;
    fn from_slice_be(values: &[U]) -> T;
    fn from_slice_le(values: &[U]) -> T;
    fn from_slice_ne(values: &[U]) -> T;
}
Available on crate feature join only.
Expand description

Offers methods to construct a primitive from an array or slice of smaller primitives.

Methods expecting an array are more efficient than the ones expecting an slice. On the other hand slices of any lenght are supported as follows:

  • If the slice contains fewer elements than required, the method will fill in the missing values with zeros.
  • If the slice contains more elements than required, the method will ignore the extra elements.

See also the Cast type for the equivalent const methods, and the PrimitiveSplit trait for the opposite operations.

Required Methods§

Source

fn from_array_be(values: [U; LEN]) -> T

Constructs a primitive T from an array of U in big-endian order.

Source

fn from_array_le(values: [U; LEN]) -> T

Constructs a primitive T from an array of U in little-endian order.

Source

fn from_array_ne(values: [U; LEN]) -> T

Constructs a primitive T from an array of U in native-endian order.

Source

fn from_slice_be(values: &[U]) -> T

Constructs a primitive T from a slice of U in big-endian order.

Source

fn from_slice_le(values: &[U]) -> T

Constructs a primitive T from a slice of U in little-endian order.

Source

fn from_slice_ne(values: &[U]) -> T

Constructs a primitive T from a slice of U in native-endian order.

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 PrimitiveJoin<u16, u8, 2> for u16

Source§

fn from_array_be(values: [u8; 2]) -> u16

Source§

fn from_array_le(values: [u8; 2]) -> u16

Source§

fn from_array_ne(values: [u8; 2]) -> u16

Source§

fn from_slice_be(values: &[u8]) -> u16

Source§

fn from_slice_le(values: &[u8]) -> u16

Source§

fn from_slice_ne(values: &[u8]) -> u16

Source§

impl PrimitiveJoin<u32, u8, 4> for u32

Source§

fn from_array_be(values: [u8; 4]) -> u32

Source§

fn from_array_le(values: [u8; 4]) -> u32

Source§

fn from_array_ne(values: [u8; 4]) -> u32

Source§

fn from_slice_be(values: &[u8]) -> u32

Source§

fn from_slice_le(values: &[u8]) -> u32

Source§

fn from_slice_ne(values: &[u8]) -> u32

Source§

impl PrimitiveJoin<u32, u16, 2> for u32

Source§

fn from_array_be(values: [u16; 2]) -> u32

Source§

fn from_array_le(values: [u16; 2]) -> u32

Source§

fn from_array_ne(values: [u16; 2]) -> u32

Source§

fn from_slice_be(values: &[u16]) -> u32

Source§

fn from_slice_le(values: &[u16]) -> u32

Source§

fn from_slice_ne(values: &[u16]) -> u32

Source§

impl PrimitiveJoin<u64, u8, 8> for u64

Source§

fn from_array_be(values: [u8; 8]) -> u64

Source§

fn from_array_le(values: [u8; 8]) -> u64

Source§

fn from_array_ne(values: [u8; 8]) -> u64

Source§

fn from_slice_be(values: &[u8]) -> u64

Source§

fn from_slice_le(values: &[u8]) -> u64

Source§

fn from_slice_ne(values: &[u8]) -> u64

Source§

impl PrimitiveJoin<u64, u16, 4> for u64

Source§

fn from_array_be(values: [u16; 4]) -> u64

Source§

fn from_array_le(values: [u16; 4]) -> u64

Source§

fn from_array_ne(values: [u16; 4]) -> u64

Source§

fn from_slice_be(values: &[u16]) -> u64

Source§

fn from_slice_le(values: &[u16]) -> u64

Source§

fn from_slice_ne(values: &[u16]) -> u64

Source§

impl PrimitiveJoin<u64, u32, 2> for u64

Source§

fn from_array_be(values: [u32; 2]) -> u64

Source§

fn from_array_le(values: [u32; 2]) -> u64

Source§

fn from_array_ne(values: [u32; 2]) -> u64

Source§

fn from_slice_be(values: &[u32]) -> u64

Source§

fn from_slice_le(values: &[u32]) -> u64

Source§

fn from_slice_ne(values: &[u32]) -> u64

Source§

impl PrimitiveJoin<u128, u8, 16> for u128

Source§

fn from_array_be(values: [u8; 16]) -> u128

Source§

fn from_array_le(values: [u8; 16]) -> u128

Source§

fn from_array_ne(values: [u8; 16]) -> u128

Source§

fn from_slice_be(values: &[u8]) -> u128

Source§

fn from_slice_le(values: &[u8]) -> u128

Source§

fn from_slice_ne(values: &[u8]) -> u128

Source§

impl PrimitiveJoin<u128, u16, 8> for u128

Source§

fn from_array_be(values: [u16; 8]) -> u128

Source§

fn from_array_le(values: [u16; 8]) -> u128

Source§

fn from_array_ne(values: [u16; 8]) -> u128

Source§

fn from_slice_be(values: &[u16]) -> u128

Source§

fn from_slice_le(values: &[u16]) -> u128

Source§

fn from_slice_ne(values: &[u16]) -> u128

Source§

impl PrimitiveJoin<u128, u32, 4> for u128

Source§

fn from_array_be(values: [u32; 4]) -> u128

Source§

fn from_array_le(values: [u32; 4]) -> u128

Source§

fn from_array_ne(values: [u32; 4]) -> u128

Source§

fn from_slice_be(values: &[u32]) -> u128

Source§

fn from_slice_le(values: &[u32]) -> u128

Source§

fn from_slice_ne(values: &[u32]) -> u128

Source§

impl PrimitiveJoin<u128, u64, 2> for u128

Source§

fn from_array_be(values: [u64; 2]) -> u128

Source§

fn from_array_le(values: [u64; 2]) -> u128

Source§

fn from_array_ne(values: [u64; 2]) -> u128

Source§

fn from_slice_be(values: &[u64]) -> u128

Source§

fn from_slice_le(values: &[u64]) -> u128

Source§

fn from_slice_ne(values: &[u64]) -> u128

Implementors§