Skip to main content

UnderlierType

Trait UnderlierType 

Source
pub trait UnderlierType:
    Debug
    + Default
    + Eq
    + Ord
    + Copy
    + Random
    + NoUninit
    + Zeroable
    + Sized
    + Send
    + Sync
    + 'static
    + BitAnd<Self, Output = Self>
    + BitAndAssign<Self>
    + BitOr<Self, Output = Self>
    + BitOrAssign<Self>
    + BitXor<Self, Output = Self>
    + BitXorAssign<Self>
    + Shr<usize, Output = Self>
    + Shl<usize, Output = Self>
    + Not<Output = Self>
    + Divisible<SmallU<1>> {
    const LOG_BITS: usize;
    const ZERO: Self;
    const ONE: Self;
    const ONES: Self;
    const BITS: usize = _;

    // Required method
    fn interleave(self, other: Self, log_block_len: usize) -> (Self, Self);

    // Provided methods
    fn fill_with_bit(val: u8) -> Self { ... }
    fn transpose(self, other: Self, log_block_len: usize) -> (Self, Self) { ... }
    fn from_fn<T>(f: impl FnMut(usize) -> T) -> Self
       where T: UnderlierType,
             Self: Divisible<T> { ... }
    fn broadcast_subvalue<T>(value: T) -> Self
       where T: UnderlierType,
             Self: Divisible<T> { ... }
    unsafe fn get_subvalue<T>(&self, i: usize) -> T
       where T: UnderlierType,
             Self: Divisible<T> { ... }
    unsafe fn set_subvalue<T>(&mut self, i: usize, val: T)
       where T: UnderlierType,
             Self: Divisible<T> { ... }
    unsafe fn spread<T>(self, log_block_len: usize, block_idx: usize) -> Self
       where T: UnderlierType,
             Self: Divisible<T> { ... }
}
Expand description

Primitive integer underlying a binary field or packed binary field implementation. Note that this type is not guaranteed to be POD, U1, U2 and U4 have some unused bits.

Required Associated Constants§

Source

const LOG_BITS: usize

Number of bits in value

Source

const ZERO: Self

Source

const ONE: Self

Source

const ONES: Self

Provided Associated Constants§

Source

const BITS: usize = _

Number of bits used to represent a value. This may not be equal to the number of bits in a type instance.

Required Methods§

Source

fn interleave(self, other: Self, log_block_len: usize) -> (Self, Self)

Interleave with the given bit size

Provided Methods§

Source

fn fill_with_bit(val: u8) -> Self

Fill value with the given bit val must be 0 or 1.

Source

fn transpose(self, other: Self, log_block_len: usize) -> (Self, Self)

Transpose with the given bit size

Source

fn from_fn<T>(f: impl FnMut(usize) -> T) -> Self
where T: UnderlierType, Self: Divisible<T>,

Source

fn broadcast_subvalue<T>(value: T) -> Self
where T: UnderlierType, Self: Divisible<T>,

Broadcast subvalue to fill Self. Self::BITS/T::BITS is supposed to be a power of 2.

Source

unsafe fn get_subvalue<T>(&self, i: usize) -> T
where T: UnderlierType, Self: Divisible<T>,

Gets the subvalue from the given position. Function panics in case when index is out of range.

§Safety

i must be less than Self::BITS/T::BITS.

Source

unsafe fn set_subvalue<T>(&mut self, i: usize, val: T)
where T: UnderlierType, Self: Divisible<T>,

Sets the subvalue in the given position. Function panics in case when index is out of range.

§Safety

i must be less than Self::BITS/T::BITS.

Source

unsafe fn spread<T>(self, log_block_len: usize, block_idx: usize) -> Self
where T: UnderlierType, Self: Divisible<T>,

Spread takes a block of sub_elements of T type within the current value and repeats them to the full underlier width.

§Safety

log_block_len + T::LOG_BITS must be less than or equal to Self::LOG_BITS. block_idx must be less than 1 << (Self::LOG_BITS - log_block_len).

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 UnderlierType for u8

Source§

const LOG_BITS: usize

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

const ONES: Self = Self::MAX

Source§

fn interleave(self, other: Self, log_block_len: usize) -> (Self, Self)

Source§

impl UnderlierType for u16

Source§

const LOG_BITS: usize

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

const ONES: Self = Self::MAX

Source§

fn interleave(self, other: Self, log_block_len: usize) -> (Self, Self)

Source§

impl UnderlierType for u32

Source§

const LOG_BITS: usize

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

const ONES: Self = Self::MAX

Source§

fn interleave(self, other: Self, log_block_len: usize) -> (Self, Self)

Source§

impl UnderlierType for u64

Source§

const LOG_BITS: usize

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

const ONES: Self = Self::MAX

Source§

fn interleave(self, other: Self, log_block_len: usize) -> (Self, Self)

Source§

impl UnderlierType for u128

Source§

const LOG_BITS: usize

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

const ONES: Self = Self::MAX

Source§

fn interleave(self, other: Self, log_block_len: usize) -> (Self, Self)

Implementors§

Source§

impl UnderlierType for M128

Source§

const LOG_BITS: usize = 7

Source§

const ZERO: Self

Source§

const ONE: Self

Source§

const ONES: Self