Struct decstr::Bitstring32

source ·
pub struct Bitstring32(_);
Expand description

A 32bit decimal number.

Implementations§

source§

impl Bitstring32

source

pub fn from_le_bytes(bytes: [u8; 4]) -> Self

Create a decimal from the given buffer.

The buffer is assumed to be in little-endian byte-order already.

source

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

Get a reference to the underlying bitstring buffer.

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

source

pub fn zero() -> Self

Create a decimal with the finite value zero.

source

pub fn max() -> Self

Create a decimal with its maximum finite value.

source

pub fn min() -> Self

Create a decimal with its minimum finite value.

source

pub fn min_positive() -> Self

Create a decimal with its minimum positive non-zero value.

source§

impl Bitstring32

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 Bitstring32

source

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

Try parse a decimal from a string.

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

source

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

Try parse a decimal from some formattable value.

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

source§

impl Bitstring32

source

pub fn from_f32(f: f32) -> Option<Bitstring32>

Try convert a binary floating point into a decimal.

source§

impl Bitstring32

source

pub fn from_f64(f: f64) -> Option<Bitstring32>

Try convert a binary floating point into a decimal.

source§

impl Bitstring32

source

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

Try convert a decimal into a binary floating point.

source§

impl Bitstring32

source

pub fn to_f64(&self) -> f64

Convert a decimal into a binary floating point.

source§

impl Bitstring32

source

pub fn from_i8(i: i8) -> Bitstring32

Convert an integer into a decimal.

source§

impl Bitstring32

source

pub fn from_i16(i: i16) -> Bitstring32

Convert an integer into a decimal.

source§

impl Bitstring32

source

pub fn from_i32(i: i32) -> Option<Bitstring32>

Try convert an integer into a decimal.

source§

impl Bitstring32

source

pub fn from_i64(i: i64) -> Option<Bitstring32>

Try convert an integer into a decimal.

source§

impl Bitstring32

source

pub fn from_i128(i: i128) -> Option<Bitstring32>

Try convert an integer into a decimal.

source§

impl Bitstring32

source

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

Try convert a decimal into an integer.

source§

impl Bitstring32

source

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

Try convert a decimal into an integer.

source§

impl Bitstring32

source

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

Try convert a decimal into an integer.

source§

impl Bitstring32

source

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

Try convert a decimal into an integer.

source§

impl Bitstring32

source

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

Try convert a decimal into an integer.

source§

impl Bitstring32

source

pub fn from_u8(i: u8) -> Bitstring32

Convert an integer into a decimal.

source§

impl Bitstring32

source

pub fn from_u16(i: u16) -> Bitstring32

Convert an integer into a decimal.

source§

impl Bitstring32

source

pub fn from_u32(i: u32) -> Option<Bitstring32>

Try convert an integer into a decimal.

source§

impl Bitstring32

source

pub fn from_u64(i: u64) -> Option<Bitstring32>

Try convert an integer into a decimal.

source§

impl Bitstring32

source

pub fn from_u128(i: u128) -> Option<Bitstring32>

Try convert an integer into a decimal.

source§

impl Bitstring32

source

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

Try convert a decimal into an integer.

source§

impl Bitstring32

source

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

Try convert a decimal into an integer.

source§

impl Bitstring32

source

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

Try convert a decimal into an integer.

source§

impl Bitstring32

source

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

Try convert a decimal into an integer.

source§

impl Bitstring32

source

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

Try convert a decimal into an integer.

Trait Implementations§

source§

impl Clone for Bitstring32

source§

fn clone(&self) -> Bitstring32

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 Bitstring32

source§

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

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

impl Display for Bitstring32

source§

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

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

impl From<Bitstring32> for f64

source§

fn from(d: Bitstring32) -> f64

Converts to this type from the input type.
source§

impl From<i16> for Bitstring32

source§

fn from(i: i16) -> Bitstring32

Converts to this type from the input type.
source§

impl From<i8> for Bitstring32

source§

fn from(i: i8) -> Bitstring32

Converts to this type from the input type.
source§

impl From<u16> for Bitstring32

source§

fn from(i: u16) -> Bitstring32

Converts to this type from the input type.
source§

impl From<u8> for Bitstring32

source§

fn from(i: u8) -> Bitstring32

Converts to this type from the input type.
source§

impl FromStr for Bitstring32

§

type Err = Error

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

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

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

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

§

type Error = Error

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

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

Performs the conversion.
source§

impl TryFrom<Bitstring32> for f32

§

type Error = Error

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

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

Performs the conversion.
source§

impl TryFrom<Bitstring32> for i128

§

type Error = Error

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

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

Performs the conversion.
source§

impl TryFrom<Bitstring32> for i16

§

type Error = Error

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

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

Performs the conversion.
source§

impl TryFrom<Bitstring32> for i32

§

type Error = Error

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

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

Performs the conversion.
source§

impl TryFrom<Bitstring32> for i64

§

type Error = Error

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

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

Performs the conversion.
source§

impl TryFrom<Bitstring32> for i8

§

type Error = Error

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

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

Performs the conversion.
source§

impl TryFrom<Bitstring32> for u128

§

type Error = Error

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

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

Performs the conversion.
source§

impl TryFrom<Bitstring32> for u16

§

type Error = Error

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

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

Performs the conversion.
source§

impl TryFrom<Bitstring32> for u32

§

type Error = Error

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

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

Performs the conversion.
source§

impl TryFrom<Bitstring32> for u64

§

type Error = Error

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

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

Performs the conversion.
source§

impl TryFrom<Bitstring32> for u8

§

type Error = Error

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

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

Performs the conversion.
source§

impl TryFrom<f32> for Bitstring32

§

type Error = Error

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

fn try_from(f: f32) -> Result<Bitstring32, Self::Error>

Performs the conversion.
source§

impl TryFrom<f64> for Bitstring32

§

type Error = Error

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

fn try_from(f: f64) -> Result<Bitstring32, Self::Error>

Performs the conversion.
source§

impl TryFrom<i128> for Bitstring32

§

type Error = Error

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

fn try_from(i: i128) -> Result<Bitstring32, Self::Error>

Performs the conversion.
source§

impl TryFrom<i32> for Bitstring32

§

type Error = Error

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

fn try_from(i: i32) -> Result<Bitstring32, Self::Error>

Performs the conversion.
source§

impl TryFrom<i64> for Bitstring32

§

type Error = Error

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

fn try_from(i: i64) -> Result<Bitstring32, Self::Error>

Performs the conversion.
source§

impl TryFrom<u128> for Bitstring32

§

type Error = Error

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

fn try_from(i: u128) -> Result<Bitstring32, Self::Error>

Performs the conversion.
source§

impl TryFrom<u32> for Bitstring32

§

type Error = Error

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

fn try_from(i: u32) -> Result<Bitstring32, Self::Error>

Performs the conversion.
source§

impl TryFrom<u64> for Bitstring32

§

type Error = Error

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

fn try_from(i: u64) -> Result<Bitstring32, Self::Error>

Performs the conversion.
source§

impl Copy for Bitstring32

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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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.
const: unstable · 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.
const: unstable · source§

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

Performs the conversion.