bitstream_io

Trait SignedNumeric

Source
pub trait SignedNumeric: Numeric {
    // Required methods
    fn is_negative(self) -> bool;
    fn as_negative(self, bits: u32) -> Self;
    fn as_negative_fixed<const BITS: u32>(self) -> Self;
    fn as_unsigned(self, bits: u32) -> Self;
    fn as_unsigned_fixed<const BITS: u32>(self) -> Self;
    fn signed_value(self) -> SignedValue;
}
Expand description

This trait extends many common signed integer types so that they can be used with the bitstream handling traits.

Required Methods§

Source

fn is_negative(self) -> bool

Returns true if this value is negative

Source

fn as_negative(self, bits: u32) -> Self

Given a two-complement positive value and certain number of bits, returns this value as a negative number.

Source

fn as_negative_fixed<const BITS: u32>(self) -> Self

Given a two-complement positive value and certain number of bits, returns this value as a negative number.

Source

fn as_unsigned(self, bits: u32) -> Self

Given a negative value and a certain number of bits, returns this value as a twos-complement positive number.

Source

fn as_unsigned_fixed<const BITS: u32>(self) -> Self

Given a negative value and a certain number of bits, returns this value as a twos-complement positive number.

Source

fn signed_value(self) -> SignedValue

Converts to a generic signed value for stream recording purposes.

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 SignedNumeric for i8

Source§

fn is_negative(self) -> bool

Source§

fn as_negative(self, bits: u32) -> Self

Source§

fn as_negative_fixed<const BITS: u32>(self) -> Self

Source§

fn as_unsigned(self, bits: u32) -> Self

Source§

fn as_unsigned_fixed<const BITS: u32>(self) -> Self

Source§

fn signed_value(self) -> SignedValue

Source§

impl SignedNumeric for i16

Source§

fn is_negative(self) -> bool

Source§

fn as_negative(self, bits: u32) -> Self

Source§

fn as_negative_fixed<const BITS: u32>(self) -> Self

Source§

fn as_unsigned(self, bits: u32) -> Self

Source§

fn as_unsigned_fixed<const BITS: u32>(self) -> Self

Source§

fn signed_value(self) -> SignedValue

Source§

impl SignedNumeric for i32

Source§

fn is_negative(self) -> bool

Source§

fn as_negative(self, bits: u32) -> Self

Source§

fn as_negative_fixed<const BITS: u32>(self) -> Self

Source§

fn as_unsigned(self, bits: u32) -> Self

Source§

fn as_unsigned_fixed<const BITS: u32>(self) -> Self

Source§

fn signed_value(self) -> SignedValue

Source§

impl SignedNumeric for i64

Source§

fn is_negative(self) -> bool

Source§

fn as_negative(self, bits: u32) -> Self

Source§

fn as_negative_fixed<const BITS: u32>(self) -> Self

Source§

fn as_unsigned(self, bits: u32) -> Self

Source§

fn as_unsigned_fixed<const BITS: u32>(self) -> Self

Source§

fn signed_value(self) -> SignedValue

Source§

impl SignedNumeric for i128

Source§

fn is_negative(self) -> bool

Source§

fn as_negative(self, bits: u32) -> Self

Source§

fn as_negative_fixed<const BITS: u32>(self) -> Self

Source§

fn as_unsigned(self, bits: u32) -> Self

Source§

fn as_unsigned_fixed<const BITS: u32>(self) -> Self

Source§

fn signed_value(self) -> SignedValue

Implementors§