Struct substreams::scalar::BigDecimal

source ·
pub struct BigDecimal(/* private fields */);

Implementations§

source§

impl BigDecimal

source

pub const MIN_EXP: i32 = -6_143i32

These are the limits of IEEE-754 decimal128, a format we may want to switch to.

See https://en.wikipedia.org/wiki/Decimal128_floating-point_format

source

pub const MAX_EXP: i32 = 6_144i32

source

pub const MAX_SIGNIFICANT_DIGITS: i32 = 34i32

source

pub fn new(digits: BigInt, exp: i64) -> Self

source

pub fn parse_bytes(bytes: &[u8]) -> Option<Self>

source

pub fn zero() -> BigDecimal

source

pub fn one() -> BigDecimal

source

pub fn as_bigint_and_exponent(&self) -> (BigInt, i64)

source

pub fn digits(&self) -> u64

source

pub fn is_zero(&self) -> bool

source

pub fn with_prec(&self, prec: u64) -> BigDecimal

source

pub fn neg(&self) -> BigDecimal

source

pub fn from_store_bytes(bytes: &[u8]) -> BigDecimal

source

pub fn divide_by_decimals( big_decimal_amount: BigDecimal, decimals: u64, ) -> BigDecimal

source

pub fn absolute(&self) -> BigDecimal

source

pub fn to_bigint(&self) -> BigInt

Trait Implementations§

source§

impl Add<BigDecimal> for BigInt

§

type Output = BigDecimal

The resulting type after applying the + operator.
source§

fn add(self, other: BigDecimal) -> BigDecimal

Performs the + operation. Read more
source§

impl<T> Add<T> for BigDecimal
where T: Into<BigDecimal>,

§

type Output = BigDecimal

The resulting type after applying the + operator.
source§

fn add(self, other: T) -> BigDecimal

Performs the + operation. Read more
source§

impl AsRef<BigDecimal> for BigDecimal

source§

fn as_ref(&self) -> &BigDecimal

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for BigDecimal

source§

fn clone(&self) -> BigDecimal

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 BigDecimal

source§

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

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

impl Default for BigDecimal

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Display for BigDecimal

source§

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

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

impl Div<&BigDecimal> for BigDecimal

§

type Output = BigDecimal

The resulting type after applying the / operator.
source§

fn div(self, other: &BigDecimal) -> BigDecimal

Performs the / operation. Read more
source§

impl Div<BigDecimal> for BigInt

§

type Output = BigDecimal

The resulting type after applying the / operator.
source§

fn div(self, other: BigDecimal) -> BigDecimal

Performs the / operation. Read more
source§

impl<T> Div<T> for BigDecimal
where T: Into<BigDecimal>,

§

type Output = BigDecimal

The resulting type after applying the / operator.
source§

fn div(self, rhs: T) -> BigDecimal

Performs the / operation. Read more
source§

impl From<&BigDecimal> for BigDecimal

source§

fn from(big_decimal: &BigDecimal) -> Self

Converts to this type from the input type.
source§

impl From<BigDecimal> for BigDecimal

source§

fn from(big_decimal: BigDecimal) -> Self

Converts to this type from the input type.
source§

impl From<BigInt> for BigDecimal

source§

fn from(n: BigInt) -> Self

Converts to this type from the input type.
source§

impl From<BigUint> for BigDecimal

source§

fn from(val: BigUint) -> Self

Converts to this type from the input type.
source§

impl From<i32> for BigDecimal

source§

fn from(n: i32) -> Self

Converts to this type from the input type.
source§

impl From<i64> for BigDecimal

source§

fn from(n: i64) -> Self

Converts to this type from the input type.
source§

impl From<u32> for BigDecimal

source§

fn from(n: u32) -> Self

Converts to this type from the input type.
source§

impl From<u64> for BigDecimal

source§

fn from(n: u64) -> Self

Converts to this type from the input type.
source§

impl From<usize> for BigDecimal

source§

fn from(n: usize) -> Self

Converts to this type from the input type.
source§

impl FromStr for BigDecimal

§

type Err = <BigDecimal as FromStr>::Err

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

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

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

impl Into<BigDecimal> for &BigInt

source§

fn into(self) -> BigDecimal

Converts this type into the (usually inferred) input type.
source§

impl Into<BigDecimal> for BigDecimal

source§

fn into(self) -> BigDecimal

Converts this type into the (usually inferred) input type.
source§

impl Into<String> for &BigDecimal

source§

fn into(self) -> String

Converts this type into the (usually inferred) input type.
source§

impl Into<String> for BigDecimal

source§

fn into(self) -> String

Converts this type into the (usually inferred) input type.
source§

impl Mul<BigDecimal> for BigInt

§

type Output = BigDecimal

The resulting type after applying the * operator.
source§

fn mul(self, other: BigDecimal) -> BigDecimal

Performs the * operation. Read more
source§

impl<T> Mul<T> for BigDecimal
where T: Into<BigDecimal>,

§

type Output = BigDecimal

The resulting type after applying the * operator.
source§

fn mul(self, rhs: T) -> BigDecimal

Performs the * operation. Read more
source§

impl Ord for BigDecimal

source§

fn cmp(&self, other: &BigDecimal) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for BigDecimal

source§

fn eq(&self, other: &BigDecimal) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for BigDecimal

source§

fn partial_cmp(&self, other: &BigDecimal) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl StoreGet<BigDecimal> for StoreGetBigDecimal

source§

fn new(idx: u32) -> Self

source§

fn get_at<K: AsRef<str>>(&self, ord: u64, key: K) -> Option<BigDecimal>

source§

fn get_last<K: AsRef<str>>(&self, key: K) -> Option<BigDecimal>

source§

fn get_first<K: AsRef<str>>(&self, key: K) -> Option<BigDecimal>

source§

fn has_at<K: AsRef<str>>(&self, ord: u64, key: K) -> bool

source§

fn has_last<K: AsRef<str>>(&self, key: K) -> bool

source§

fn has_first<K: AsRef<str>>(&self, key: K) -> bool

source§

impl StoreSet<BigDecimal> for StoreSetBigDecimal

source§

fn set<K: AsRef<str>>(&self, ord: u64, key: K, value: &BigDecimal)

Set a given key to a given value, if the key existed before, it will be replaced.
source§

fn set_many<K: AsRef<str>>(&self, ord: u64, keys: &Vec<K>, value: &BigDecimal)

Set many keys to a given values, if the key existed before, it will be replaced.
source§

impl StoreSetIfNotExists<BigDecimal> for StoreSetIfNotExistsBigDecimal

source§

fn set_if_not_exists<K: AsRef<str>>(&self, ord: u64, key: K, value: &BigDecimal)

Set a given key to a given value, if the key existed before, it will be ignored and not set.
source§

fn set_if_not_exists_many<K: AsRef<str>>( &self, ord: u64, keys: &Vec<K>, value: &BigDecimal, )

Set given keys to given values, if the key existed before, it will be ignored and not set.
source§

impl StoreSetSum<BigDecimal> for StoreSetSumBigDecimal

source§

fn new() -> Self

source§

fn set<K: AsRef<str>>(&self, ord: u64, key: K, value: BigDecimal)

source§

fn sum<K: AsRef<str>>(&self, ord: u64, key: K, value: BigDecimal)

source§

impl Sub<BigDecimal> for BigInt

§

type Output = BigDecimal

The resulting type after applying the - operator.
source§

fn sub(self, other: BigDecimal) -> BigDecimal

Performs the - operation. Read more
source§

impl<T> Sub<T> for BigDecimal
where T: Into<BigDecimal>,

§

type Output = BigDecimal

The resulting type after applying the - operator.
source§

fn sub(self, other: T) -> BigDecimal

Performs the - operation. Read more
source§

impl ToPrimitive for BigDecimal

source§

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

Converts the value of self to an i64. If the value cannot be represented by an i64, then None is returned.
source§

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

Converts the value of self to a u64. If the value cannot be represented by a u64, then None is returned.
source§

fn to_isize(&self) -> Option<isize>

Converts the value of self to an isize. If the value cannot be represented by an isize, then None is returned.
source§

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

Converts the value of self to an i8. If the value cannot be represented by an i8, then None is returned.
source§

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

Converts the value of self to an i16. If the value cannot be represented by an i16, then None is returned.
source§

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

Converts the value of self to an i32. If the value cannot be represented by an i32, then None is returned.
source§

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

Converts the value of self to an i128. If the value cannot be represented by an i128 (i64 under the default implementation), then None is returned. Read more
source§

fn to_usize(&self) -> Option<usize>

Converts the value of self to a usize. If the value cannot be represented by a usize, then None is returned.
source§

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

Converts the value of self to a u8. If the value cannot be represented by a u8, then None is returned.
source§

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

Converts the value of self to a u16. If the value cannot be represented by a u16, then None is returned.
source§

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

Converts the value of self to a u32. If the value cannot be represented by a u32, then None is returned.
source§

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

Converts the value of self to a u128. If the value cannot be represented by a u128 (u64 under the default implementation), then None is returned. Read more
source§

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

Converts the value of self to an f32. Overflows may map to positive or negative inifinity, otherwise None is returned if the value cannot be represented by an f32.
source§

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

Converts the value of self to an f64. Overflows may map to positive or negative inifinity, otherwise None is returned if the value cannot be represented by an f64. Read more
source§

impl TryFrom<&String> for BigDecimal

§

type Error = ParseBigDecimalError

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

fn try_from(value: &String) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<&str> for BigDecimal

§

type Error = ParseBigDecimalError

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

fn try_from(value: &str) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<String> for BigDecimal

§

type Error = ParseBigDecimalError

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

fn try_from(value: String) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<f32> for BigDecimal

§

type Error = ParseBigDecimalError

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

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

Performs the conversion.
source§

impl TryFrom<f64> for BigDecimal

§

type Error = ParseBigDecimalError

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

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

Performs the conversion.
source§

impl Eq for BigDecimal

source§

impl StructuralPartialEq for BigDecimal

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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 T
where 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 T
where 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 T
where 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 T
where 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 T
where 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.