use alloc::borrow::Cow;
use icu_pattern::{DoublePlaceholderPattern, SinglePlaceholderPattern};
use icu_provider::prelude::*;
use tinystr::TinyAsciiStr;
use zerovec::{
ule::{AsULE, ULE},
ZeroMap, ZeroMap2d, ZeroSlice, ZeroVec,
};
use icu_timezone::{provider::IsoMinutesSinceEpoch, TimeZoneBcp47Id, ZoneVariant};
pub(crate) mod tz {
pub(crate) use super::LocationsV1;
pub(crate) use super::LocationsV1Marker;
pub(crate) use super::MetazoneGenericNamesLongV1Marker as MzGenericLongV1Marker;
pub(crate) use super::MetazoneGenericNamesShortV1Marker as MzGenericShortV1Marker;
pub(crate) use super::MetazoneGenericNamesV1 as MzGenericV1;
pub(crate) use super::MetazonePeriodV1 as MzPeriodV1;
pub(crate) use super::MetazonePeriodV1Marker as MzPeriodV1Marker;
pub(crate) use super::MetazoneSpecificNamesLongV1Marker as MzSpecificLongV1Marker;
pub(crate) use super::MetazoneSpecificNamesShortV1Marker as MzSpecificShortV1Marker;
pub(crate) use super::MetazoneSpecificNamesV1 as MzSpecificV1;
pub(crate) use super::TimeZoneEssentialsV1 as EssentialsV1;
pub(crate) use super::TimeZoneEssentialsV1Marker as EssentialsV1Marker;
}
#[icu_provider::data_struct(TimeZoneEssentialsV1Marker = "time_zone/essentials@1")]
#[derive(PartialEq, Debug, Clone, Default)]
#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))]
#[cfg_attr(feature = "datagen", databake(path = icu_datetime::provider::time_zones))]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
#[yoke(prove_covariance_manually)]
pub struct TimeZoneEssentialsV1<'data> {
#[cfg_attr(feature = "serde", serde(borrow,))]
pub offset_separator: Cow<'data, str>,
#[cfg_attr(
feature = "serde",
serde(
borrow,
deserialize_with = "icu_pattern::deserialize_borrowed_cow::<icu_pattern::SinglePlaceholder, _>"
)
)]
pub offset_pattern: Cow<'data, SinglePlaceholderPattern>,
#[cfg_attr(feature = "serde", serde(borrow))]
pub offset_zero: Cow<'data, str>,
#[cfg_attr(feature = "serde", serde(borrow))]
pub offset_unknown: Cow<'data, str>,
}
#[icu_provider::data_struct(LocationsV1Marker = "time_zone/locations@1")]
#[derive(PartialEq, Debug, Clone, Default)]
#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))]
#[cfg_attr(feature = "datagen", databake(path = icu_datetime::provider::time_zones))]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
#[yoke(prove_covariance_manually)]
pub struct LocationsV1<'data> {
#[cfg_attr(feature = "serde", serde(borrow))]
pub locations: ZeroMap<'data, TimeZoneBcp47Id, str>,
#[cfg_attr(
feature = "serde",
serde(
borrow,
deserialize_with = "icu_pattern::deserialize_borrowed_cow::<icu_pattern::SinglePlaceholder, _>"
)
)]
pub pattern_generic: Cow<'data, SinglePlaceholderPattern>,
#[cfg_attr(
feature = "serde",
serde(
borrow,
deserialize_with = "icu_pattern::deserialize_borrowed_cow::<icu_pattern::SinglePlaceholder, _>"
)
)]
pub pattern_standard: Cow<'data, SinglePlaceholderPattern>,
#[cfg_attr(
feature = "serde",
serde(
borrow,
deserialize_with = "icu_pattern::deserialize_borrowed_cow::<icu_pattern::SinglePlaceholder, _>"
)
)]
pub pattern_daylight: Cow<'data, SinglePlaceholderPattern>,
#[cfg_attr(
feature = "serde",
serde(
borrow,
deserialize_with = "icu_pattern::deserialize_borrowed_cow::<icu_pattern::DoublePlaceholder, _>"
)
)]
pub pattern_partial_location: Cow<'data, DoublePlaceholderPattern>,
}
#[icu_provider::data_struct(
marker(MetazoneGenericNamesLongV1Marker, "time_zone/generic_long@1"),
marker(MetazoneGenericNamesShortV1Marker, "time_zone/generic_short@1")
)]
#[derive(PartialEq, Debug, Clone, Default)]
#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))]
#[cfg_attr(feature = "datagen", databake(path = icu_datetime::provider::time_zones))]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
#[yoke(prove_covariance_manually)]
pub struct MetazoneGenericNamesV1<'data> {
#[cfg_attr(feature = "serde", serde(borrow))]
pub defaults: ZeroMap<'data, MetazoneId, str>,
#[cfg_attr(feature = "serde", serde(borrow))]
pub overrides: ZeroMap<'data, TimeZoneBcp47Id, str>,
}
#[icu_provider::data_struct(
marker(MetazoneSpecificNamesLongV1Marker, "time_zone/specific_long@1"),
marker(MetazoneSpecificNamesShortV1Marker, "time_zone/specific_short@1")
)]
#[derive(PartialEq, Debug, Clone, Default)]
#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))]
#[cfg_attr(feature = "datagen", databake(path = icu_datetime::provider::time_zones))]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
#[yoke(prove_covariance_manually)]
pub struct MetazoneSpecificNamesV1<'data> {
#[cfg_attr(feature = "serde", serde(borrow))]
pub defaults: ZeroMap<'data, (MetazoneId, ZoneVariant), str>,
#[cfg_attr(feature = "serde", serde(borrow))]
pub overrides: ZeroMap<'data, (TimeZoneBcp47Id, ZoneVariant), str>,
}
#[repr(transparent)]
#[derive(Debug, Clone, Copy, Eq, Ord, PartialEq, PartialOrd, yoke::Yokeable, ULE, Hash)]
#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))]
#[cfg_attr(feature = "datagen", databake(path = icu_datetime::provider::time_zones))]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
pub struct MetazoneId(pub TinyAsciiStr<4>);
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))]
#[cfg_attr(feature = "datagen", databake(path = icu_datetime::provider::time_zones))]
#[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, IsoMinutesSinceEpoch, Option<MetazoneId>>,
);