vortex_scalar/decimal/
mod.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4use std::fmt::{Debug, Display};
5
6use crate::{BigCast, i256};
7
8mod scalar;
9pub use scalar::*;
10
11mod value;
12pub use value::{DecimalValue, DecimalValueType};
13
14/// Type of decimal scalar values.
15///
16/// This trait is implemented by native integer types that can be used to store decimal values.
17pub trait NativeDecimalType:
18    Copy + Eq + Ord + Default + Send + Sync + BigCast + Debug + Display + 'static
19{
20    /// The decimal value type corresponding to this native type.
21    const VALUES_TYPE: DecimalValueType;
22
23    /// Attempts to convert a decimal value to this native type.
24    fn maybe_from(decimal_type: DecimalValue) -> Option<Self>;
25}
26
27mod macros;
28use macros::impl_native_decimal_type;
29
30impl_native_decimal_type!(i8, I8);
31impl_native_decimal_type!(i16, I16);
32impl_native_decimal_type!(i32, I32);
33impl_native_decimal_type!(i64, I64);
34impl_native_decimal_type!(i128, I128);
35impl_native_decimal_type!(i256, I256);
36
37#[cfg(test)]
38mod tests;