Struct decstr::Bitstring

source ·
pub struct Bitstring(_);
Expand description

A dynamically sized decimal number with enough precision to fit any Rust primitive number.

Implementations§

source§

impl Bitstring

source

pub fn try_from_le_bytes(bytes: &[u8]) -> Result<Self, Error>

Try create a decimal from the given buffer.

The buffer is assumed to be in little-endian byte-order already. This method will fail if the buffer length is not a multiple of 4 bytes, or it’s too big to fit in a Bitstring.

source

pub fn as_le_bytes(&self) -> &[u8]

Get a reference to the underlying bitstring buffer.

This buffer is always stored in little-endian byte-order, regardless of the endianness of the platform.

source

pub fn zero() -> Self

Create a decimal with the finite value zero.

source§

impl Bitstring

source

pub fn is_sign_negative(&self) -> bool

Whether or not the sign bit is set.

source

pub fn is_finite(&self) -> bool

Whether or not the decimal is a finite number.

source

pub fn is_infinite(&self) -> bool

Whether or not the decimal is an infinity.

source

pub fn is_nan(&self) -> bool

Whether the decimal is not a NaN.

source

pub fn is_quiet_nan(&self) -> bool

Whether the decimal is a qNaN.

source

pub fn is_signaling_nan(&self) -> bool

Whether the decimal is a sNaN.

source§

impl Bitstring

source

pub fn try_parse_str(s: &str) -> Result<Bitstring, Error>

Try parse a decimal from a string.

This method is more efficient than try_parse if you already have a string to parse.

source

pub fn try_parse(n: impl Display) -> Result<Bitstring, Error>

Try parse a decimal from some formattable value.

This method can avoid needing to buffer an entire number upfront.

source§

impl Bitstring

source

pub fn from_f32(f: f32) -> Bitstring

Convert a binary floating point into a decimal.

source§

impl Bitstring

source

pub fn from_f64(f: f64) -> Bitstring

Convert a binary floating point into a decimal.

source§

impl Bitstring

source

pub fn to_f32(&self) -> Option<f32>

Try convert a decimal into a binary floating point.

source§

impl Bitstring

source

pub fn to_f64(&self) -> Option<f64>

Try convert a decimal into a binary floating point.

source§

impl Bitstring

source

pub fn from_i8(i: i8) -> Bitstring

Convert an integer into a decimal.

source§

impl Bitstring

source

pub fn from_i16(i: i16) -> Bitstring

Convert an integer into a decimal.

source§

impl Bitstring

source

pub fn from_i32(i: i32) -> Bitstring

Convert an integer into a decimal.

source§

impl Bitstring

source

pub fn from_i64(i: i64) -> Bitstring

Convert an integer into a decimal.

source§

impl Bitstring

source

pub fn from_i128(i: i128) -> Bitstring

Convert an integer into a decimal.

source§

impl Bitstring

source

pub fn to_i8(&self) -> Option<i8>

Try convert a decimal into an integer.

source§

impl Bitstring

source

pub fn to_i16(&self) -> Option<i16>

Try convert a decimal into an integer.

source§

impl Bitstring

source

pub fn to_i32(&self) -> Option<i32>

Try convert a decimal into an integer.

source§

impl Bitstring

source

pub fn to_i64(&self) -> Option<i64>

Try convert a decimal into an integer.

source§

impl Bitstring

source

pub fn to_i128(&self) -> Option<i128>

Try convert a decimal into an integer.

source§

impl Bitstring

source

pub fn from_u8(i: u8) -> Bitstring

Convert an integer into a decimal.

source§

impl Bitstring

source

pub fn from_u16(i: u16) -> Bitstring

Convert an integer into a decimal.

source§

impl Bitstring

source

pub fn from_u32(i: u32) -> Bitstring

Convert an integer into a decimal.

source§

impl Bitstring

source

pub fn from_u64(i: u64) -> Bitstring

Convert an integer into a decimal.

source§

impl Bitstring

source

pub fn from_u128(i: u128) -> Bitstring

Convert an integer into a decimal.

source§

impl Bitstring

source

pub fn to_u8(&self) -> Option<u8>

Try convert a decimal into an integer.

source§

impl Bitstring

source

pub fn to_u16(&self) -> Option<u16>

Try convert a decimal into an integer.

source§

impl Bitstring

source

pub fn to_u32(&self) -> Option<u32>

Try convert a decimal into an integer.

source§

impl Bitstring

source

pub fn to_u64(&self) -> Option<u64>

Try convert a decimal into an integer.

source§

impl Bitstring

source

pub fn to_u128(&self) -> Option<u128>

Try convert a decimal into an integer.

Trait Implementations§

source§

impl Clone for Bitstring

source§

fn clone(&self) -> Bitstring

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Bitstring

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Bitstring

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<f32> for Bitstring

source§

fn from(f: f32) -> Bitstring

Converts to this type from the input type.
source§

impl From<f64> for Bitstring

source§

fn from(f: f64) -> Bitstring

Converts to this type from the input type.
source§

impl From<i128> for Bitstring

source§

fn from(i: i128) -> Bitstring

Converts to this type from the input type.
source§

impl From<i16> for Bitstring

source§

fn from(i: i16) -> Bitstring

Converts to this type from the input type.
source§

impl From<i32> for Bitstring

source§

fn from(i: i32) -> Bitstring

Converts to this type from the input type.
source§

impl From<i64> for Bitstring

source§

fn from(i: i64) -> Bitstring

Converts to this type from the input type.
source§

impl From<i8> for Bitstring

source§

fn from(i: i8) -> Bitstring

Converts to this type from the input type.
source§

impl From<u128> for Bitstring

source§

fn from(i: u128) -> Bitstring

Converts to this type from the input type.
source§

impl From<u16> for Bitstring

source§

fn from(i: u16) -> Bitstring

Converts to this type from the input type.
source§

impl From<u32> for Bitstring

source§

fn from(i: u32) -> Bitstring

Converts to this type from the input type.
source§

impl From<u64> for Bitstring

source§

fn from(i: u64) -> Bitstring

Converts to this type from the input type.
source§

impl From<u8> for Bitstring

source§

fn from(i: u8) -> Bitstring

Converts to this type from the input type.
source§

impl FromStr for Bitstring

§

type Err = Error

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Bitstring, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl<'a> TryFrom<&'a str> for Bitstring

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(s: &'a str) -> Result<Bitstring, Self::Error>

Performs the conversion.
source§

impl TryFrom<Bitstring> for f32

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(d: Bitstring) -> Result<f32, Self::Error>

Performs the conversion.
source§

impl TryFrom<Bitstring> for f64

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(d: Bitstring) -> Result<f64, Self::Error>

Performs the conversion.
source§

impl TryFrom<Bitstring> for i128

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(d: Bitstring) -> Result<i128, Self::Error>

Performs the conversion.
source§

impl TryFrom<Bitstring> for i16

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(d: Bitstring) -> Result<i16, Self::Error>

Performs the conversion.
source§

impl TryFrom<Bitstring> for i32

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(d: Bitstring) -> Result<i32, Self::Error>

Performs the conversion.
source§

impl TryFrom<Bitstring> for i64

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(d: Bitstring) -> Result<i64, Self::Error>

Performs the conversion.
source§

impl TryFrom<Bitstring> for i8

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(d: Bitstring) -> Result<i8, Self::Error>

Performs the conversion.
source§

impl TryFrom<Bitstring> for u128

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(d: Bitstring) -> Result<u128, Self::Error>

Performs the conversion.
source§

impl TryFrom<Bitstring> for u16

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(d: Bitstring) -> Result<u16, Self::Error>

Performs the conversion.
source§

impl TryFrom<Bitstring> for u32

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(d: Bitstring) -> Result<u32, Self::Error>

Performs the conversion.
source§

impl TryFrom<Bitstring> for u64

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(d: Bitstring) -> Result<u64, Self::Error>

Performs the conversion.
source§

impl TryFrom<Bitstring> for u8

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(d: Bitstring) -> Result<u8, Self::Error>

Performs the conversion.
source§

impl Copy for Bitstring

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.