Skip to content

Commit

Permalink
Add separate rounding modes for unsigned and signed fixed decimals
Browse files Browse the repository at this point in the history
  • Loading branch information
younies committed Nov 4, 2024
1 parent b863dea commit c593589
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions ffi/capi/src/fixed_decimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,30 @@ pub mod ffi {
MultiplesOf25,
}

/// Mode used in a rounding operation.
#[diplomat::rust_link(fixed_decimal::RoundingMode, Enum)]
#[diplomat::enum_convert(fixed_decimal::RoundingMode, needs_wildcard)]
pub enum FixedDecimalRoundingMode {
Ceil,
/// Mode used in a rounding operation for unsigned numbers.
#[diplomat::rust_link(fixed_decimal::UnsignedRoundingMode, Enum)]
#[diplomat::enum_convert(fixed_decimal::UnsignedRoundingMode, needs_wildcard)]
pub enum FixedDecimalUnsignedRoundingMode {
Expand,
Floor,
Trunc,
HalfCeil,
HalfExpand,
HalfFloor,
HalfTrunc,
HalfEven,
}

/// Mode used in a rounding operation for signed numbers.
#[diplomat::rust_link(fixed_decimal::SignedRoundingMode, Enum)]
#[diplomat::enum_convert(fixed_decimal::SignedRoundingMode, needs_wildcard)]
pub enum FixedDecimalRoundingMode {
// TODO:Uncomment this once we have a way to convert from UnsignedRoundingMode to SignedRoundingMode.
// TODO: this must be done.
// Unsigned(FixedDecimalUnsignedRoundingMode),
Ceil,
Floor,
HalfCeil,
HalfFloor,
}

impl SignedFixedDecimal {
/// Construct an [`FixedDecimal`] from an integer.
#[diplomat::rust_link(fixed_decimal::FixedDecimal, Struct)]
Expand Down

0 comments on commit c593589

Please sign in to comment.