Debian Codegraph @

intl/icu_capi/src/metazone_calculator.rs

raw
1 // This file is part of ICU4X. For terms of use, please see the file
2 // called LICENSE at the top level of the ICU4X source tree
3 // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
4
5 #[diplomat::bridge]
6 pub mod ffi {
7 use crate::errors::ffi::ICU4XError;
8 use crate::provider::ffi::ICU4XDataProvider;
9 use alloc::boxed::Box;
10 use icu_timezone::MetazoneCalculator;
11
12 /// An object capable of computing the metazone from a timezone.
13 ///
14 /// This can be used via `maybe_calculate_metazone()` on [`ICU4XCustomTimeZone`].
15 ///
16 /// [`ICU4XCustomTimeZone`]: crate::timezone::ffi::ICU4XCustomTimeZone
17 #[diplomat::opaque]
18 #[diplomat::rust_link(icu::timezone::MetazoneCalculator, Struct)]
19 pub struct ICU4XMetazoneCalculator(pub MetazoneCalculator);
20
21 impl ICU4XMetazoneCalculator {
22 #[diplomat::rust_link(icu::timezone::MetazoneCalculator::new, FnInStruct)]
23 #[diplomat::attr(all(supports = constructors, supports = fallible_constructors), constructor)]
24 pub fn create(
25 provider: &ICU4XDataProvider,
26 ) -> Result<Box<ICU4XMetazoneCalculator>, ICU4XError> {
27 Ok(Box::new(ICU4XMetazoneCalculator(call_constructor!(
28 MetazoneCalculator::new [r => Ok(r)],
29 MetazoneCalculator::try_new_with_any_provider,
30 MetazoneCalculator::try_new_with_buffer_provider,
31 provider,
32 )?)))
33 }
34 }
35 }