#![allow(clippy::exhaustive_structs, clippy::exhaustive_enums)]
use core::ops::Deref;
use core::str::FromStr;
use icu_provider::prelude::*;
use tinystr::TinyAsciiStr;
use zerovec::ule::{AsULE, ULE};
use zerovec::{ZeroMap2d, ZeroSlice, ZeroVec};
pub mod names;
#[cfg(feature = "compiled_data")]
#[derive(Debug)]
pub struct Baked;
#[cfg(feature = "compiled_data")]
const _: () = {
pub mod icu {
pub use crate as timezone;
}
icu_timezone_data::make_provider!(Baked);
icu_timezone_data::impl_time_zone_bcp47_to_iana_v1!(Baked);
icu_timezone_data::impl_time_zone_iana_to_bcp47_v1!(Baked);
icu_timezone_data::impl_time_zone_iana_to_bcp47_v2!(Baked);
icu_timezone_data::impl_time_zone_metazone_period_v1!(Baked);
};
#[cfg(feature = "datagen")]
pub const KEYS: &[DataKey] = &[
MetazonePeriodV1Marker::KEY,
names::Bcp47ToIanaMapV1Marker::KEY,
names::IanaToBcp47MapV1Marker::KEY,
names::IanaToBcp47MapV2Marker::KEY,
];
#[repr(transparent)]
#[derive(Debug, Clone, Copy, Eq, Ord, PartialEq, PartialOrd, yoke::Yokeable, ULE, Hash)]
#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake), databake(path = icu_timezone::provider))]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
pub struct TimeZoneBcp47Id(pub TinyAsciiStr<8>);
impl FromStr for TimeZoneBcp47Id {
type Err = tinystr::TinyStrError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
TinyAsciiStr::from_str(s).map(Into::into)
}
}
impl From<TinyAsciiStr<8>> for TimeZoneBcp47Id {
fn from(s: TinyAsciiStr<8>) -> Self {
Self(s)
}
}
impl From<TimeZoneBcp47Id> for TinyAsciiStr<8> {
fn from(other: TimeZoneBcp47Id) -> Self {
other.0
}
}
impl Deref for TimeZoneBcp47Id {
type Target = TinyAsciiStr<8>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl AsULE for TimeZoneBcp47Id {
type ULE = Self;
#[inline]
fn to_unaligned(self) -> Self::ULE {
self
}
#[inline]
fn from_unaligned(unaligned: Self::ULE) -> Self {
unaligned
}
}
impl<'a> zerovec::maps::ZeroMapKV<'a> for TimeZoneBcp47Id {
type Container = ZeroVec<'a, TimeZoneBcp47Id>;
type Slice = ZeroSlice<TimeZoneBcp47Id>;
type GetType = TimeZoneBcp47Id;
type OwnedType = TimeZoneBcp47Id;
}
#[repr(transparent)]
#[derive(Debug, Clone, Copy, Eq, Ord, PartialEq, PartialOrd, yoke::Yokeable, ULE, Hash)]
#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake), databake(path = icu_timezone::provider))]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
pub struct MetazoneId(pub TinyAsciiStr<4>);
impl From<TinyAsciiStr<4>> for MetazoneId {
fn from(s: TinyAsciiStr<4>) -> Self {
Self(s)
}
}
impl From<MetazoneId> for TinyAsciiStr<4> {
fn from(other: MetazoneId) -> Self {
other.0
}
}
impl FromStr for MetazoneId {
type Err = tinystr::TinyStrError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
TinyAsciiStr::from_str(s).map(Into::into)
}
}
impl AsULE for MetazoneId {
type ULE = Self;
#[inline]
fn to_unaligned(self) -> Self::ULE {
self
}
#[inline]
fn from_unaligned(unaligned: Self::ULE) -> Self {
unaligned
}
}
impl<'a> zerovec::maps::ZeroMapKV<'a> for MetazoneId {
type Container = ZeroVec<'a, MetazoneId>;
type Slice = ZeroSlice<MetazoneId>;
type GetType = MetazoneId;
type OwnedType = MetazoneId;
}
#[icu_provider::data_struct(marker(
MetazonePeriodV1Marker,
"time_zone/metazone_period@1",
singleton
))]
#[derive(PartialEq, Debug, Clone, Default)]
#[cfg_attr(
feature = "datagen",
derive(serde::Serialize, databake::Bake),
databake(path = icu_timezone::provider),
)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
#[yoke(prove_covariance_manually)]
pub struct MetazonePeriodV1<'data>(
#[cfg_attr(feature = "serde", serde(borrow))]
pub ZeroMap2d<'data, TimeZoneBcp47Id, i32, Option<MetazoneId>>,
);