Skip to main content

Crate paft_decimal

Crate paft_decimal 

Source
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
Decimal represents a 128 bit representation of a fixed-precision decimal number. The finite set of values of type Decimal are 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.
DecimalConstraintError
Error returned when a decimal does not satisfy a constrained decimal type.
NonNegativeDecimal
Decimal constrained to x >= 0.
PositiveDecimal
Decimal constrained to x > 0.
Ratio
Decimal constrained to 0 <= x <= 1.

Enums§

RoundingStrategy
Rounding strategy supported by decimal operations.

Constants§

MAX_DECIMAL_PRECISION
Maximum fractional precision supported by the active decimal backend.

Traits§

Decimal128Mantissa
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.