1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
// This file is part of ICU4X. For terms of use, please see the file
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
//! 🚧 \[Unstable\] Property names-related data for this component
//!
//! <div class="stab unstable">
//! 🚧 This code is considered unstable; it may change at any time, in breaking or non-breaking ways,
//! including in SemVer minor releases. While the serde representation of data structs is guaranteed
//! to be stable, their Rust representation might not be. Use with caution.
//! </div>
//!
//! Read more about data providers: [`icu_provider`]
use crate::TimeZoneBcp47Id;
use core::str;
use icu_provider::prelude::*;
use zerotrie::ZeroTrie;
use zerovec::{VarZeroVec, ZeroVec};
/// A mapping from IANA time zone identifiers to BCP-47 time zone identifiers.
///
/// Multiple IANA time zone IDs can map to the same BCP-47 time zone ID.
///
/// <div class="stab unstable">
/// 🚧 This code is considered unstable; it may change at any time, in breaking or non-breaking ways,
/// including in SemVer minor releases. While the serde representation of data structs is guaranteed
/// to be stable, their Rust representation might not be. Use with caution.
/// </div>
#[derive(Debug, Clone, PartialEq)]
#[icu_provider::data_struct(marker(
IanaToBcp47MapV1Marker,
"time_zone/iana_to_bcp47@1",
singleton
))]
#[cfg_attr(
feature = "datagen",
derive(serde::Serialize, databake::Bake),
databake(path = icu_timezone::provider::names),
)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
#[yoke(prove_covariance_manually)]
pub struct IanaToBcp47MapV1<'data> {
/// A map from IANA time zone identifiers to indexes of BCP-47 time zone identifiers.
#[cfg_attr(feature = "serde", serde(borrow))]
pub map: ZeroTrie<ZeroVec<'data, u8>>,
/// A sorted list of BCP-47 time zone identifiers.
#[cfg_attr(feature = "serde", serde(borrow))]
// Note: this is 9739B as ZeroVec<TinyStr8> and 9335B as VarZeroVec<str>
pub bcp47_ids: ZeroVec<'data, TimeZoneBcp47Id>,
/// An XxHash64 checksum of [`Self::bcp47_ids`].
pub bcp47_ids_checksum: u64,
}
/// A mapping from IANA time zone identifiers to BCP-47 time zone identifiers.
///
/// The BCP-47 time zone ID maps to the default IANA time zone ID according to the CLDR data.
///
/// <div class="stab unstable">
/// 🚧 This code is considered unstable; it may change at any time, in breaking or non-breaking ways,
/// including in SemVer minor releases. While the serde representation of data structs is guaranteed
/// to be stable, their Rust representation might not be. Use with caution.
/// </div>
#[derive(Debug, Clone, PartialEq)]
#[icu_provider::data_struct(marker(
Bcp47ToIanaMapV1Marker,
"time_zone/bcp47_to_iana@1",
singleton
))]
#[cfg_attr(
feature = "datagen",
derive(serde::Serialize, databake::Bake),
databake(path = icu_timezone::provider::names),
)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
#[yoke(prove_covariance_manually)]
pub struct Bcp47ToIanaMapV1<'data> {
/// An XxHash64 checksum of [`IanaToBcp47MapV1::bcp47_ids`].
///
/// The checksum here should match the checksum in [`IanaToBcp47MapV1`]
/// if these were generated from the same data set.
pub bcp47_ids_checksum: u64,
/// The IANA time zone identifier corresponding to the BCP-47 ID in
/// [`IanaToBcp47MapV1::bcp47_ids`].
///
/// Since there can be more than one IANA identifier for a particular
/// BCP-47 identifier, this list contains only the current canonical
/// IANA identifier.
#[cfg_attr(feature = "serde", serde(borrow))]
pub canonical_iana_ids: VarZeroVec<'data, str>,
}