Expand description
Backend-agnostic decimal helpers shared across the paft workspace.
The crate wraps rust_decimal by default and can
switch to bigdecimal via the optional
bigdecimal feature. It exposes a consistent Decimal type alongside rounding
strategies and utility helpers for parsing, scaling, and canonical rendering
without pulling in higher-level money abstractions.
Modules§
- serde
- Serde helpers for backend-stable decimal wire formats.
Structs§
- Decimal
Decimalrepresents a 128 bit representation of a fixed-precision decimal number. The finite set of values of typeDecimalare of the form m / 10e, where m is an integer such that -296 < m < 296, and e is an integer between 0 and 28 inclusive.- Decimal
Constraint Error - Error returned when a decimal does not satisfy a constrained decimal type.
- NonNegative
Decimal - Decimal constrained to
x >= 0. - Positive
Decimal - Decimal constrained to
x > 0. - Ratio
- Decimal constrained to
0 <= x <= 1.
Enums§
- Rounding
Strategy - Rounding strategy supported by decimal operations.
Constants§
- MAX_
DECIMAL_ PRECISION - Maximum fractional precision supported by the active decimal backend.
Traits§
- Decimal128
Mantissa - Encodes decimal-like values into Polars-compatible decimal128 mantissas.
- ToPrimitive
- A generic trait for converting a value to a number.
Functions§
- checked_
add - Adds two decimals if the active backend can represent the result.
- checked_
div - Divides two decimals if the active backend can represent the result.
- checked_
mul - Multiplies two decimals if the active backend can represent the result.
- checked_
sub - Subtracts two decimals if the active backend can represent the result.
- clone_
decimal - Clones a decimal value using the active backend’s cheapest owned-value path.
- fractional_
digit_ count - Returns the number of fractional digits represented by the active backend.
- from_
minor_ units - Builds a decimal from an integer count of minor units and the provided scale.
- max_
decimal_ precision - Returns the maximum fractional precision supported by the active decimal backend.
- one
- Returns the one value for the active decimal backend.
- parse_
decimal - Parses a plain decimal string using the active backend.
- round_
dp_ with_ strategy - Rounds a decimal to the requested scale using a rounding strategy.
- to_
canonical_ string - Converts a decimal into a canonical string without scientific notation and without gratuitous trailing zeros.
- try_
from_ scaled_ units - Builds a decimal from an integer coefficient and scale if the active backend can represent it.
- try_
to_ scaled_ units - Converts a decimal into exact base-10 scaled integer units.
- zero
- Returns the zero value for the active decimal backend.