1use super::*;
6use icu_locid::subtags::{Language, Region, Script};
7use icu_provider::prelude::*;
8use zerovec::ZeroMap;
9
10#[icu_provider::data_struct(marker(
11 LikelySubtagsV1Marker,
12 "locid_transform/likelysubtags@1",
13 singleton
14))]
15#[derive(Debug, PartialEq, Clone)]
16#[cfg_attr(
17 feature = "datagen",
18 derive(serde::Serialize, databake::Bake),
19 databake(path = icu_locid_transform::provider),
20)]
21#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
22#[yoke(prove_covariance_manually)]
41pub struct LikelySubtagsV1<'data> {
42 #[cfg_attr(feature = "serde", serde(borrow))]
44 pub language_script: ZeroMap<'data, (UnvalidatedLanguage, UnvalidatedScript), Region>,
45 #[cfg_attr(feature = "serde", serde(borrow))]
47 pub language_region: ZeroMap<'data, (UnvalidatedLanguage, UnvalidatedRegion), Script>,
48 #[cfg_attr(feature = "serde", serde(borrow))]
50 pub language: ZeroMap<'data, UnvalidatedLanguage, (Script, Region)>,
51 #[cfg_attr(feature = "serde", serde(borrow))]
53 pub script_region: ZeroMap<'data, (UnvalidatedScript, UnvalidatedRegion), Language>,
54 #[cfg_attr(feature = "serde", serde(borrow))]
56 pub script: ZeroMap<'data, UnvalidatedScript, (Language, Region)>,
57 #[cfg_attr(feature = "serde", serde(borrow))]
59 pub region: ZeroMap<'data, UnvalidatedRegion, (Language, Script)>,
60 pub und: (Language, Script, Region),
62}
63
64#[icu_provider::data_struct(marker(
65 LikelySubtagsForLanguageV1Marker,
66 "locid_transform/likelysubtags_l@1",
67 singleton
68))]
69#[derive(Debug, PartialEq, Clone)]
70#[cfg_attr(
71 feature = "datagen",
72 derive(serde::Serialize, databake::Bake),
73 databake(path = icu_locid_transform::provider),
74)]
75#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
76#[yoke(prove_covariance_manually)]
98pub struct LikelySubtagsForLanguageV1<'data> {
99 #[cfg_attr(feature = "serde", serde(borrow))]
101 pub language_script: ZeroMap<'data, (UnvalidatedLanguage, UnvalidatedScript), Region>,
102 #[cfg_attr(feature = "serde", serde(borrow))]
104 pub language_region: ZeroMap<'data, (UnvalidatedLanguage, UnvalidatedRegion), Script>,
105 #[cfg_attr(feature = "serde", serde(borrow))]
107 pub language: ZeroMap<'data, UnvalidatedLanguage, (Script, Region)>,
108 pub und: (Language, Script, Region),
110}
111
112impl<'data> From<LikelySubtagsV1<'data>> for LikelySubtagsForLanguageV1<'data> {
113 fn from(other: LikelySubtagsV1<'data>) -> Self {
114 Self {
115 language_script: other.language_script,
116 language_region: other.language_region,
117 language: other.language,
118 und: other.und,
119 }
120 }
121}
122
123impl<'data> LikelySubtagsForLanguageV1<'data> {
124 pub(crate) fn clone_from_borrowed(other: &LikelySubtagsV1<'data>) -> Self {
125 Self {
126 language_script: other.language_script.clone(),
127 language_region: other.language_region.clone(),
128 language: other.language.clone(),
129 und: other.und,
130 }
131 }
132}
133
134#[icu_provider::data_struct(marker(
135 LikelySubtagsForScriptRegionV1Marker,
136 "locid_transform/likelysubtags_sr@1",
137 singleton
138))]
139#[derive(Debug, PartialEq, Clone)]
140#[cfg_attr(
141 feature = "datagen",
142 derive(serde::Serialize, databake::Bake),
143 databake(path = icu_locid_transform::provider),
144)]
145#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
146#[yoke(prove_covariance_manually)]
168pub struct LikelySubtagsForScriptRegionV1<'data> {
169 #[cfg_attr(feature = "serde", serde(borrow))]
171 pub script_region: ZeroMap<'data, (UnvalidatedScript, UnvalidatedRegion), Language>,
172 #[cfg_attr(feature = "serde", serde(borrow))]
174 pub script: ZeroMap<'data, UnvalidatedScript, (Language, Region)>,
175 #[cfg_attr(feature = "serde", serde(borrow))]
177 pub region: ZeroMap<'data, UnvalidatedRegion, (Language, Script)>,
178}
179
180impl<'data> From<LikelySubtagsV1<'data>> for LikelySubtagsForScriptRegionV1<'data> {
181 fn from(other: LikelySubtagsV1<'data>) -> Self {
182 Self {
183 script_region: other.script_region,
184 script: other.script,
185 region: other.region,
186 }
187 }
188}
189
190#[icu_provider::data_struct(marker(
191 LikelySubtagsExtendedV1Marker,
192 "locid_transform/likelysubtags_ext@1",
193 singleton
194))]
195#[derive(Debug, PartialEq, Clone)]
196#[cfg_attr(
197 feature = "datagen",
198 derive(serde::Serialize, databake::Bake),
199 databake(path = icu_locid_transform::provider),
200)]
201#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
202#[yoke(prove_covariance_manually)]
211pub struct LikelySubtagsExtendedV1<'data> {
212 #[cfg_attr(feature = "serde", serde(borrow))]
214 pub language_script: ZeroMap<'data, (UnvalidatedLanguage, UnvalidatedScript), Region>,
215 #[cfg_attr(feature = "serde", serde(borrow))]
217 pub language_region: ZeroMap<'data, (UnvalidatedLanguage, UnvalidatedRegion), Script>,
218 #[cfg_attr(feature = "serde", serde(borrow))]
220 pub language: ZeroMap<'data, UnvalidatedLanguage, (Script, Region)>,
221 #[cfg_attr(feature = "serde", serde(borrow))]
223 pub script_region: ZeroMap<'data, (UnvalidatedScript, UnvalidatedRegion), Language>,
224 #[cfg_attr(feature = "serde", serde(borrow))]
226 pub script: ZeroMap<'data, UnvalidatedScript, (Language, Region)>,
227 #[cfg_attr(feature = "serde", serde(borrow))]
229 pub region: ZeroMap<'data, UnvalidatedRegion, (Language, Script)>,
230}
231
232impl<'data> From<LikelySubtagsV1<'data>> for LikelySubtagsExtendedV1<'data> {
233 fn from(other: LikelySubtagsV1<'data>) -> Self {
234 Self {
235 language_script: other.language_script,
236 language_region: other.language_region,
237 language: other.language,
238 script_region: other.script_region,
239 script: other.script,
240 region: other.region,
241 }
242 }
243}