Struct icu_timezone::iana_ids::IanaBcp47RoundTripMapper

source ·
pub struct IanaBcp47RoundTripMapper {
    data1: DataPayload<IanaToBcp47MapV1Marker>,
    data2: DataPayload<Bcp47ToIanaMapV1Marker>,
}
👎Deprecated since 1.5.0: use TimeZoneIdMapper instead
Expand 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 instead
§data2: DataPayload<Bcp47ToIanaMapV1Marker>
👎Deprecated since 1.5.0: use TimeZoneIdMapper instead

Implementations§

source§

impl IanaBcp47RoundTripMapper

source

pub const fn new() -> Self

Creates a new IanaBcp47RoundTripMapper using compiled data.

See IanaBcp47RoundTripMapper for an example.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

source

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.

📚 Help choosing a constructor

source

pub fn try_new_unstable<P>(provider: &P) -> Result<Self, TimeZoneError>

A version of Self::new that uses custom data provided by a DataProvider.

📚 Help choosing a constructor

⚠️ The bounds on provider may change over time, including in SemVer minor releases.
source

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

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for IanaBcp47RoundTripMapper

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T