#![allow(clippy::exhaustive_structs, clippy::exhaustive_enums)]
use icu_pattern::SinglePlaceholderPattern;
use icu_plurals::provider::PluralElementsPackedCow;
use icu_provider::prelude::*;
#[icu_provider::data_struct(marker(
UnitsDisplayNameV1Marker,
"units/displaynames@1",
attributes_domain = "units"
))]
#[derive(Clone, PartialEq, Debug)]
#[cfg_attr(feature = "datagen", derive(serde::Serialize))]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
#[yoke(prove_covariance_manually)]
pub struct UnitsDisplayNameV1<'data> {
#[cfg_attr(feature = "serde", serde(borrow))]
pub patterns: PluralElementsPackedCow<'data, SinglePlaceholderPattern>,
}
impl<'data> UnitsDisplayNameV1<'data> {
pub const unsafe fn from_bytes_unchecked(bytes: &'data [u8]) -> Self {
Self {
patterns: icu_plurals::provider::PluralElementsPackedCow {
elements: alloc::borrow::Cow::Borrowed(
icu_plurals::provider::PluralElementsPackedULE::from_bytes_unchecked(bytes),
),
},
}
}
}
#[cfg(feature = "datagen")]
impl databake::Bake for UnitsDisplayNameV1<'_> {
fn bake(&self, ctx: &databake::CrateEnv) -> databake::TokenStream {
use zerovec::ule::VarULE;
ctx.insert("icu_experimental::dimension::provider::units");
let bytes = self.patterns.elements.as_bytes().bake(ctx);
databake::quote! { unsafe {
icu_experimental::dimension::provider::units::UnitsDisplayNameV1::from_bytes_unchecked(#bytes)
}}
}
}
#[cfg(feature = "datagen")]
impl databake::BakeSize for UnitsDisplayNameV1<'_> {
fn borrows_size(&self) -> usize {
self.patterns.borrows_size()
}
}