pub struct Decimal<T: DecimalType> { /* private fields */ }
Expand description
Decimal
is the generic representation of a single decimal value
See Decimal128
and Decimal256
for the value types of Decimal128Array
and Decimal256Array
respectively
Implementations
sourceimpl<T: DecimalType> Decimal<T>
impl<T: DecimalType> Decimal<T>
pub const MAX_PRECISION: usize = T::MAX_PRECISION
pub const MAX_SCALE: usize = T::MAX_SCALE
pub const TYPE_CONSTRUCTOR: fn(_: usize, _: usize) -> DataType = T::TYPE_CONSTRUCTOR
pub const DEFAULT_TYPE: DataType = T::DEFAULT_TYPE
sourcepub fn try_new_from_bytes(
precision: usize,
scale: usize,
bytes: &T::Native
) -> Result<Self> where
Self: Sized,
pub fn try_new_from_bytes(
precision: usize,
scale: usize,
bytes: &T::Native
) -> Result<Self> where
Self: Sized,
Tries to create a decimal value from precision, scale and bytes. The bytes should be stored in little-endian order.
Safety: This method doesn’t validate if the decimal value represented by the bytes can be fitted into the specified precision.
sourcepub fn new(precision: usize, scale: usize, bytes: &T::Native) -> Self
pub fn new(precision: usize, scale: usize, bytes: &T::Native) -> Self
Creates a decimal value from precision, scale, and bytes.
Safety:
This method doesn’t check if the precision and scale are valid.
Use try_new_from_bytes
for safe constructor.
sourceimpl Decimal<Decimal128Type>
impl Decimal<Decimal128Type>
sourceimpl Decimal<Decimal256Type>
impl Decimal<Decimal256Type>
sourcepub fn from_big_int(
num: &BigInt,
precision: usize,
scale: usize
) -> Result<Decimal256>
pub fn from_big_int(
num: &BigInt,
precision: usize,
scale: usize
) -> Result<Decimal256>
Constructs a Decimal256
value from a BigInt
.
Trait Implementations
sourceimpl<T: DecimalType> Clone for Decimal<T>
impl<T: DecimalType> Clone for Decimal<T>
Manually implement to avoid T: Debug
bound
sourceimpl<T: DecimalType> Debug for Decimal<T>
impl<T: DecimalType> Debug for Decimal<T>
Manually implement to avoid T: Debug
bound
sourceimpl From<Decimal<Decimal128Type>> for i128
impl From<Decimal<Decimal128Type>> for i128
sourcefn from(decimal: Decimal128) -> Self
fn from(decimal: Decimal128) -> Self
Converts to this type from the input type.
sourceimpl<T: DecimalType> Ord for Decimal<T>
impl<T: DecimalType> Ord for Decimal<T>
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<T: DecimalType> PartialEq<Decimal<T>> for Decimal<T>
impl<T: DecimalType> PartialEq<Decimal<T>> for Decimal<T>
sourceimpl<T: DecimalType> PartialOrd<Decimal<T>> for Decimal<T>
impl<T: DecimalType> PartialOrd<Decimal<T>> for Decimal<T>
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
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 · sourcefn le(&self, other: &Rhs) -> bool
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
impl<T: DecimalType> Copy for Decimal<T>
impl<T: DecimalType> Eq for Decimal<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for Decimal<T> where
<T as DecimalType>::Native: RefUnwindSafe,
impl<T> Send for Decimal<T>
impl<T> Sync for Decimal<T>
impl<T> Unpin for Decimal<T> where
<T as DecimalType>::Native: Unpin,
impl<T> UnwindSafe for Decimal<T> where
<T as DecimalType>::Native: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.