Struct icu_timezone::iana_ids::IanaBcp47RoundTripMapper
source · pub struct IanaBcp47RoundTripMapper {
data1: DataPayload<IanaToBcp47MapV1Marker>,
data2: DataPayload<Bcp47ToIanaMapV1Marker>,
}
👎Deprecated since 1.5.0: use
TimeZoneIdMapper
insteadExpand description
A mapper that supports mapping IANA identifiers to BCP-47 identifiers and also the other way around.
This is mainly useful if the IANA identifier needs to be recovered or canonicalized.
§Examples
Demonstration of canonicalization of the time zone identifier:
use icu::timezone::IanaBcp47RoundTripMapper;
let mapper = IanaBcp47RoundTripMapper::new();
let mapper_borrowed = mapper.as_borrowed();
// Look up the time zone ID for "Asia/Calcutta"
let bcp47_id = mapper_borrowed.iana_to_bcp47("Asia/Calcutta");
assert_eq!(bcp47_id, Some("inccu".parse().unwrap()));
// Get it back as the canonical form "Asia/Kolkata"
let iana_id = mapper_borrowed.bcp47_to_iana(bcp47_id.unwrap());
assert_eq!(iana_id, Some("Asia/Kolkata"))
Fields§
§data1: DataPayload<IanaToBcp47MapV1Marker>
👎Deprecated since 1.5.0: use
§TimeZoneIdMapper
insteaddata2: DataPayload<Bcp47ToIanaMapV1Marker>
👎Deprecated since 1.5.0: use
TimeZoneIdMapper
insteadImplementations§
source§impl IanaBcp47RoundTripMapper
impl IanaBcp47RoundTripMapper
sourcepub const fn new() -> Self
pub const fn new() -> Self
Creates a new IanaBcp47RoundTripMapper
using compiled data.
See IanaBcp47RoundTripMapper
for an example.
✨ Enabled with the compiled_data
Cargo feature.
sourcepub fn try_new_with_any_provider(
provider: &(impl AnyProvider + ?Sized),
) -> Result<Self, TimeZoneError>
pub fn try_new_with_any_provider( provider: &(impl AnyProvider + ?Sized), ) -> Result<Self, TimeZoneError>
A version of [Self :: new
] that uses custom data provided by an AnyProvider
.
sourcepub fn try_new_unstable<P>(provider: &P) -> Result<Self, TimeZoneError>
pub fn try_new_unstable<P>(provider: &P) -> Result<Self, TimeZoneError>
A version of Self::new
that uses custom data provided by a DataProvider
.
⚠️ The bounds on provider may change over time, including in SemVer minor releases.
sourcepub fn as_borrowed(&self) -> IanaBcp47RoundTripMapperBorrowed<'_>
pub fn as_borrowed(&self) -> IanaBcp47RoundTripMapperBorrowed<'_>
Returns a borrowed version of the mapper that can be queried.
This avoids a small potential cost of reading the data pointer.
Trait Implementations§
source§impl Debug for IanaBcp47RoundTripMapper
impl Debug for IanaBcp47RoundTripMapper
Auto Trait Implementations§
impl Freeze for IanaBcp47RoundTripMapper
impl RefUnwindSafe for IanaBcp47RoundTripMapper
impl !Send for IanaBcp47RoundTripMapper
impl !Sync for IanaBcp47RoundTripMapper
impl Unpin for IanaBcp47RoundTripMapper
impl UnwindSafe for IanaBcp47RoundTripMapper
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more