Trait bitstream_io::Numeric

source ·
pub trait Numeric: Primitive + Sized + Copy + Default + Debug + PartialOrd + Shl<u32, Output = Self> + ShlAssign<u32> + Shr<u32, Output = Self> + ShrAssign<u32> + Rem<Self, Output = Self> + RemAssign<Self> + BitOrAssign<Self> + BitXor<Self, Output = Self> + Not<Output = Self> + Sub<Self, Output = Self> {
    const BITS_SIZE: u32;
    const ONE: Self;

    // Required methods
    fn is_zero(self) -> bool;
    fn from_u8(u: u8) -> Self;
    fn to_u8(self) -> u8;
    fn count_ones(self) -> u32;
    fn leading_zeros(self) -> u32;
    fn trailing_zeros(self) -> u32;
    fn unsigned_value(self) -> UnsignedValue;
}
Expand description

This trait extends many common integer types (both unsigned and signed) with a few trivial methods so that they can be used with the bitstream handling traits.

Required Associated Constants§

source

const BITS_SIZE: u32

Size of type in bits

source

const ONE: Self

The value of 1 in this type

Required Methods§

source

fn is_zero(self) -> bool

Returns true if this value is 0, in its type

source

fn from_u8(u: u8) -> Self

Returns a u8 value in this type

source

fn to_u8(self) -> u8

Assuming 0 <= value < 256, returns this value as a u8 type

source

fn count_ones(self) -> u32

Counts the number of 1 bits

source

fn leading_zeros(self) -> u32

Counts the number of leading zeros

source

fn trailing_zeros(self) -> u32

Counts the number of trailing zeros

source

fn unsigned_value(self) -> UnsignedValue

Convert to a generic unsigned write value for stream recording purposes

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Numeric for i8

source§

const BITS_SIZE: u32 = 8u32

source§

const ONE: Self = 1i8

source§

fn is_zero(self) -> bool

source§

fn from_u8(u: u8) -> Self

source§

fn to_u8(self) -> u8

source§

fn count_ones(self) -> u32

source§

fn leading_zeros(self) -> u32

source§

fn trailing_zeros(self) -> u32

source§

fn unsigned_value(self) -> UnsignedValue

source§

impl Numeric for i16

source§

const BITS_SIZE: u32 = 16u32

source§

const ONE: Self = 1i16

source§

fn is_zero(self) -> bool

source§

fn from_u8(u: u8) -> Self

source§

fn to_u8(self) -> u8

source§

fn count_ones(self) -> u32

source§

fn leading_zeros(self) -> u32

source§

fn trailing_zeros(self) -> u32

source§

fn unsigned_value(self) -> UnsignedValue

source§

impl Numeric for i32

source§

const BITS_SIZE: u32 = 32u32

source§

const ONE: Self = 1i32

source§

fn is_zero(self) -> bool

source§

fn from_u8(u: u8) -> Self

source§

fn to_u8(self) -> u8

source§

fn count_ones(self) -> u32

source§

fn leading_zeros(self) -> u32

source§

fn trailing_zeros(self) -> u32

source§

fn unsigned_value(self) -> UnsignedValue

source§

impl Numeric for i64

source§

const BITS_SIZE: u32 = 64u32

source§

const ONE: Self = 1i64

source§

fn is_zero(self) -> bool

source§

fn from_u8(u: u8) -> Self

source§

fn to_u8(self) -> u8

source§

fn count_ones(self) -> u32

source§

fn leading_zeros(self) -> u32

source§

fn trailing_zeros(self) -> u32

source§

fn unsigned_value(self) -> UnsignedValue

source§

impl Numeric for i128

source§

const BITS_SIZE: u32 = 128u32

source§

const ONE: Self = 1i128

source§

fn is_zero(self) -> bool

source§

fn from_u8(u: u8) -> Self

source§

fn to_u8(self) -> u8

source§

fn count_ones(self) -> u32

source§

fn leading_zeros(self) -> u32

source§

fn trailing_zeros(self) -> u32

source§

fn unsigned_value(self) -> UnsignedValue

source§

impl Numeric for u8

source§

const BITS_SIZE: u32 = 8u32

source§

const ONE: Self = 1u8

source§

fn is_zero(self) -> bool

source§

fn from_u8(u: u8) -> Self

source§

fn to_u8(self) -> u8

source§

fn count_ones(self) -> u32

source§

fn leading_zeros(self) -> u32

source§

fn trailing_zeros(self) -> u32

source§

fn unsigned_value(self) -> UnsignedValue

source§

impl Numeric for u16

source§

const BITS_SIZE: u32 = 16u32

source§

const ONE: Self = 1u16

source§

fn is_zero(self) -> bool

source§

fn from_u8(u: u8) -> Self

source§

fn to_u8(self) -> u8

source§

fn count_ones(self) -> u32

source§

fn leading_zeros(self) -> u32

source§

fn trailing_zeros(self) -> u32

source§

fn unsigned_value(self) -> UnsignedValue

source§

impl Numeric for u32

source§

const BITS_SIZE: u32 = 32u32

source§

const ONE: Self = 1u32

source§

fn is_zero(self) -> bool

source§

fn from_u8(u: u8) -> Self

source§

fn to_u8(self) -> u8

source§

fn count_ones(self) -> u32

source§

fn leading_zeros(self) -> u32

source§

fn trailing_zeros(self) -> u32

source§

fn unsigned_value(self) -> UnsignedValue

source§

impl Numeric for u64

source§

const BITS_SIZE: u32 = 64u32

source§

const ONE: Self = 1u64

source§

fn is_zero(self) -> bool

source§

fn from_u8(u: u8) -> Self

source§

fn to_u8(self) -> u8

source§

fn count_ones(self) -> u32

source§

fn leading_zeros(self) -> u32

source§

fn trailing_zeros(self) -> u32

source§

fn unsigned_value(self) -> UnsignedValue

source§

impl Numeric for u128

source§

const BITS_SIZE: u32 = 128u32

source§

const ONE: Self = 1u128

source§

fn is_zero(self) -> bool

source§

fn from_u8(u: u8) -> Self

source§

fn to_u8(self) -> u8

source§

fn count_ones(self) -> u32

source§

fn leading_zeros(self) -> u32

source§

fn trailing_zeros(self) -> u32

source§

fn unsigned_value(self) -> UnsignedValue

Implementors§