Skip to content

Commit

Permalink
Fix up rust links
Browse files Browse the repository at this point in the history
  • Loading branch information
sffc committed Aug 26, 2023
1 parent 90a8970 commit a633485
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions ffi/diplomat/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use self::ffi::ICU4XError;
use core::fmt;
#[cfg(feature = "icu_decimal")]
use fixed_decimal::Error as FixedDecimalError;
use fixed_decimal::FixedDecimalError;
#[cfg(any(
feature = "icu_datetime",
feature = "icu_timezone",
Expand Down Expand Up @@ -45,7 +45,7 @@ pub mod ffi {
/// A common enum for errors that ICU4X may return, organized by API
///
/// The error names are stable and can be checked against as strings in the JS API
#[diplomat::rust_link(fixed_decimal::Error, Enum, compact)]
#[diplomat::rust_link(fixed_decimal::FixedDecimalError, Enum, compact)]
#[diplomat::rust_link(icu::calendar::CalendarError, Enum, compact)]
#[diplomat::rust_link(icu::collator::CollatorError, Enum, compact)]
#[diplomat::rust_link(icu::datetime::DateTimeError, Enum, compact)]
Expand Down
12 changes: 8 additions & 4 deletions ffi/diplomat/src/fixed_decimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ pub mod ffi {

/// Construct an [`ICU4XFixedDecimal`] from an integer-valued float
#[diplomat::rust_link(fixed_decimal::FixedDecimal::try_from_f64, FnInStruct)]
#[diplomat::rust_link(fixed_decimal::DoublePrecision, Enum)]
#[diplomat::rust_link(fixed_decimal::FloatPrecision, Enum)]
#[diplomat::rust_link(fixed_decimal::DoublePrecision, Enum, hidden)]
pub fn create_from_f64_with_integer_precision(
f: f64,
) -> Result<Box<ICU4XFixedDecimal>, ICU4XError> {
Expand All @@ -77,7 +78,8 @@ pub mod ffi {

/// Construct an [`ICU4XFixedDecimal`] from an float, with a given power of 10 for the lower magnitude
#[diplomat::rust_link(fixed_decimal::FixedDecimal::try_from_f64, FnInStruct)]
#[diplomat::rust_link(fixed_decimal::DoublePrecision, Enum)]
#[diplomat::rust_link(fixed_decimal::FloatPrecision, Enum)]
#[diplomat::rust_link(fixed_decimal::DoublePrecision, Enum, hidden)]
pub fn create_from_f64_with_lower_magnitude(
f: f64,
magnitude: i16,
Expand All @@ -90,7 +92,8 @@ pub mod ffi {

/// Construct an [`ICU4XFixedDecimal`] from an float, for a given number of significant digits
#[diplomat::rust_link(fixed_decimal::FixedDecimal::try_from_f64, FnInStruct)]
#[diplomat::rust_link(fixed_decimal::DoublePrecision, Enum)]
#[diplomat::rust_link(fixed_decimal::FloatPrecision, Enum)]
#[diplomat::rust_link(fixed_decimal::DoublePrecision, Enum, hidden)]
pub fn create_from_f64_with_significant_digits(
f: f64,
digits: u8,
Expand All @@ -104,7 +107,8 @@ pub mod ffi {
/// Construct an [`ICU4XFixedDecimal`] from an float, with enough digits to recover
/// the original floating point in IEEE 754 without needing trailing zeros
#[diplomat::rust_link(fixed_decimal::FixedDecimal::try_from_f64, FnInStruct)]
#[diplomat::rust_link(fixed_decimal::DoublePrecision, Enum)]
#[diplomat::rust_link(fixed_decimal::FloatPrecision, Enum)]
#[diplomat::rust_link(fixed_decimal::DoublePrecision, Enum, hidden)]
pub fn create_from_f64_with_floating_precision(
f: f64,
) -> Result<Box<ICU4XFixedDecimal>, ICU4XError> {
Expand Down
1 change: 1 addition & 0 deletions tools/ffi_coverage/src/allowlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ lazy_static::lazy_static! {
"icu::datetime::options::DateTimeFormatterOptions",

// Re-exports of errors
"fixed_decimal::Error",
"icu::calendar::Error",
"icu::compactdecimal::Error",
"icu::datetime::Error",
Expand Down

0 comments on commit a633485

Please sign in to comment.