pub trait Decimal128Encode {
// Required method
fn try_to_i128_mantissa(&self, target_scale: u32) -> Option<i128>;
}Expand description
Encodes a decimal value into the i128 mantissa expected by polars
DataType::Decimal(_, _) columns.
Implementations MUST use round-half-to-even (banker’s rounding) on
scale-down so the mantissa bytes match what polars’s own
str_to_dec128 would produce. Returning None indicates the rescaled
value does not fit in i128; the caller (the df-derive codegen) surfaces
this as a PolarsError::ComputeError.
Required Methods§
Sourcefn try_to_i128_mantissa(&self, target_scale: u32) -> Option<i128>
fn try_to_i128_mantissa(&self, target_scale: u32) -> Option<i128>
Returns the mantissa as i128 after rescaling self to
target_scale, or None if the scale exceeds polars decimal
precision or the conversion would overflow.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl Decimal128Encode for QuantityAmount
Available on crate feature
dataframe only.