[][src]Trait bitstream_io::Numeric

pub trait Numeric: 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> {
    type Bytes: AsRef<[u8]> + AsMut<[u8]>;
    pub fn one() -> Self;
pub fn is_zero(self) -> bool;
pub fn from_u8(u: u8) -> Self;
pub fn to_u8(self) -> u8;
pub fn count_ones(self) -> u32;
pub fn leading_zeros(self) -> u32;
pub fn trailing_zeros(self) -> u32;
pub fn bits_size() -> u32;
pub fn buffer() -> Self::Bytes;
pub fn to_be_bytes(self) -> Self::Bytes;
pub fn to_le_bytes(self) -> Self::Bytes;
pub fn from_be_bytes(bytes: Self::Bytes) -> Self;
pub fn from_le_bytes(bytes: Self::Bytes) -> Self;
pub fn unsigned_value(self) -> UnsignedValue; }

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.

Associated Types

type Bytes: AsRef<[u8]> + AsMut<[u8]>[src]

The raw byte representation of this numeric type

Loading content...

Required methods

pub fn one() -> Self[src]

The value of 1 in this type

pub fn is_zero(self) -> bool[src]

Returns true if this value is 0, in its type

pub fn from_u8(u: u8) -> Self[src]

Returns a u8 value in this type

pub fn to_u8(self) -> u8[src]

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

pub fn count_ones(self) -> u32[src]

Counts the number of 1 bits

pub fn leading_zeros(self) -> u32[src]

Counts the number of leading zeros

pub fn trailing_zeros(self) -> u32[src]

Counts the number of trailing zeros

pub fn bits_size() -> u32[src]

Size of type in bits

pub fn buffer() -> Self::Bytes[src]

An empty buffer of this type's size

pub fn to_be_bytes(self) -> Self::Bytes[src]

Our value in big-endian bytes

pub fn to_le_bytes(self) -> Self::Bytes[src]

Our value in little-endian bytes

pub fn from_be_bytes(bytes: Self::Bytes) -> Self[src]

Convert big-endian bytes to our value

pub fn from_le_bytes(bytes: Self::Bytes) -> Self[src]

Convert little-endian bytes to out value

pub fn unsigned_value(self) -> UnsignedValue[src]

Convert to a generic unsigned write value for stream recording purposes

Loading content...

Implementations on Foreign Types

impl Numeric for u8[src]

type Bytes = [u8; 1]

impl Numeric for i8[src]

type Bytes = [u8; 1]

impl Numeric for u16[src]

type Bytes = [u8; 2]

impl Numeric for i16[src]

type Bytes = [u8; 2]

impl Numeric for u32[src]

type Bytes = [u8; 4]

impl Numeric for i32[src]

type Bytes = [u8; 4]

impl Numeric for u64[src]

type Bytes = [u8; 8]

impl Numeric for i64[src]

type Bytes = [u8; 8]

impl Numeric for u128[src]

type Bytes = [u8; 16]

impl Numeric for i128[src]

type Bytes = [u8; 16]

Loading content...

Implementors

Loading content...