• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // This file is part of ICU4X. For terms of use, please see the file
2 // called LICENSE at the top level of the ICU4X source tree
3 // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
4 
5 //! �� \[Unstable\] Property names-related data for this component
6 //!
7 //! <div class="stab unstable">
8 //! �� This code is considered unstable; it may change at any time, in breaking or non-breaking ways,
9 //! including in SemVer minor releases. While the serde representation of data structs is guaranteed
10 //! to be stable, their Rust representation might not be. Use with caution.
11 //! </div>
12 //!
13 //! Read more about data providers: [`icu_provider`]
14 
15 use icu_locale_core::subtags::Script;
16 use icu_provider::prelude::*;
17 
18 use zerotrie::ZeroTrieSimpleAscii;
19 use zerovec::ule::NichedOption;
20 use zerovec::{VarZeroVec, ZeroMap, ZeroVec};
21 
22 icu_provider::data_marker!(
23     /// `BidiClassNameToValueV2`
24     BidiClassNameToValueV2,
25     PropertyValueNameToEnumMap<'static>,
26     is_singleton = true
27 );
28 icu_provider::data_marker!(
29     /// `CanonicalCombiningClassNameToValueV2`
30     CanonicalCombiningClassNameToValueV2,
31     PropertyValueNameToEnumMap<'static>,
32     is_singleton = true
33 );
34 icu_provider::data_marker!(
35     /// `EastAsianWidthNameToValueV2`
36     EastAsianWidthNameToValueV2,
37     PropertyValueNameToEnumMap<'static>,
38     is_singleton = true
39 );
40 icu_provider::data_marker!(
41     /// `GeneralCategoryMaskNameToValueV2`
42     GeneralCategoryMaskNameToValueV2,
43     PropertyValueNameToEnumMap<'static>,
44     is_singleton = true
45 );
46 icu_provider::data_marker!(
47     /// `GeneralCategoryNameToValueV2`
48     GeneralCategoryNameToValueV2,
49     PropertyValueNameToEnumMap<'static>,
50     is_singleton = true
51 );
52 icu_provider::data_marker!(
53     /// `GraphemeClusterBreakNameToValueV2`
54     GraphemeClusterBreakNameToValueV2,
55     PropertyValueNameToEnumMap<'static>,
56     is_singleton = true
57 );
58 icu_provider::data_marker!(
59     /// `HangulSyllableTypeNameToValueV2`
60     HangulSyllableTypeNameToValueV2,
61     PropertyValueNameToEnumMap<'static>,
62     is_singleton = true
63 );
64 icu_provider::data_marker!(
65     /// `IndicSyllabicCategoryNameToValueV2`
66     IndicSyllabicCategoryNameToValueV2,
67     PropertyValueNameToEnumMap<'static>,
68     is_singleton = true
69 );
70 icu_provider::data_marker!(
71     /// `JoiningTypeNameToValueV2`
72     JoiningTypeNameToValueV2,
73     PropertyValueNameToEnumMap<'static>,
74     is_singleton = true
75 );
76 icu_provider::data_marker!(
77     /// `LineBreakNameToValueV2`
78     LineBreakNameToValueV2,
79     PropertyValueNameToEnumMap<'static>,
80     is_singleton = true
81 );
82 icu_provider::data_marker!(
83     /// `ScriptNameToValueV2`
84     ScriptNameToValueV2,
85     PropertyValueNameToEnumMap<'static>,
86     is_singleton = true
87 );
88 icu_provider::data_marker!(
89     /// `SentenceBreakNameToValueV2`
90     SentenceBreakNameToValueV2,
91     PropertyValueNameToEnumMap<'static>,
92     is_singleton = true
93 );
94 icu_provider::data_marker!(
95     /// `WordBreakNameToValueV2`
96     WordBreakNameToValueV2,
97     PropertyValueNameToEnumMap<'static>,
98     is_singleton = true
99 );
100 icu_provider::data_marker!(
101     /// `BidiClassValueToLongNameV1`
102     BidiClassValueToLongNameV1,
103     PropertyEnumToValueNameLinearMap<'static>,
104     is_singleton = true
105 );
106 icu_provider::data_marker!(
107     /// `BidiClassValueToShortNameV1`
108     BidiClassValueToShortNameV1,
109     PropertyEnumToValueNameLinearMap<'static>,
110     is_singleton = true
111 );
112 icu_provider::data_marker!(
113     /// `EastAsianWidthValueToLongNameV1`
114     EastAsianWidthValueToLongNameV1,
115     PropertyEnumToValueNameLinearMap<'static>,
116     is_singleton = true
117 );
118 icu_provider::data_marker!(
119     /// `EastAsianWidthValueToShortNameV1`
120     EastAsianWidthValueToShortNameV1,
121     PropertyEnumToValueNameLinearMap<'static>,
122     is_singleton = true
123 );
124 icu_provider::data_marker!(
125     /// `GeneralCategoryValueToLongNameV1`
126     GeneralCategoryValueToLongNameV1,
127     PropertyEnumToValueNameLinearMap<'static>,
128     is_singleton = true
129 );
130 icu_provider::data_marker!(
131     /// `GeneralCategoryValueToShortNameV1`
132     GeneralCategoryValueToShortNameV1,
133     PropertyEnumToValueNameLinearMap<'static>,
134     is_singleton = true
135 );
136 icu_provider::data_marker!(
137     /// `GraphemeClusterBreakValueToLongNameV1`
138     GraphemeClusterBreakValueToLongNameV1,
139     PropertyEnumToValueNameLinearMap<'static>,
140     is_singleton = true
141 );
142 icu_provider::data_marker!(
143     /// `GraphemeClusterBreakValueToShortNameV1`
144     GraphemeClusterBreakValueToShortNameV1,
145     PropertyEnumToValueNameLinearMap<'static>,
146     is_singleton = true
147 );
148 icu_provider::data_marker!(
149     /// `HangulSyllableTypeValueToLongNameV1`
150     HangulSyllableTypeValueToLongNameV1,
151     PropertyEnumToValueNameLinearMap<'static>,
152     is_singleton = true
153 );
154 icu_provider::data_marker!(
155     /// `HangulSyllableTypeValueToShortNameV1`
156     HangulSyllableTypeValueToShortNameV1,
157     PropertyEnumToValueNameLinearMap<'static>,
158     is_singleton = true
159 );
160 icu_provider::data_marker!(
161     /// `IndicSyllabicCategoryValueToLongNameV1`
162     IndicSyllabicCategoryValueToLongNameV1,
163     PropertyEnumToValueNameLinearMap<'static>,
164     is_singleton = true
165 );
166 icu_provider::data_marker!(
167     /// `IndicSyllabicCategoryValueToShortNameV1`
168     IndicSyllabicCategoryValueToShortNameV1,
169     PropertyEnumToValueNameLinearMap<'static>,
170     is_singleton = true
171 );
172 icu_provider::data_marker!(
173     /// `JoiningTypeValueToLongNameV1`
174     JoiningTypeValueToLongNameV1,
175     PropertyEnumToValueNameLinearMap<'static>,
176     is_singleton = true
177 );
178 icu_provider::data_marker!(
179     /// `JoiningTypeValueToShortNameV1`
180     JoiningTypeValueToShortNameV1,
181     PropertyEnumToValueNameLinearMap<'static>,
182     is_singleton = true
183 );
184 icu_provider::data_marker!(
185     /// `LineBreakValueToLongNameV1`
186     LineBreakValueToLongNameV1,
187     PropertyEnumToValueNameLinearMap<'static>,
188     is_singleton = true
189 );
190 icu_provider::data_marker!(
191     /// `LineBreakValueToShortNameV1`
192     LineBreakValueToShortNameV1,
193     PropertyEnumToValueNameLinearMap<'static>,
194     is_singleton = true
195 );
196 icu_provider::data_marker!(
197     /// `ScriptValueToLongNameV1`
198     ScriptValueToLongNameV1,
199     PropertyEnumToValueNameLinearMap<'static>,
200     is_singleton = true
201 );
202 icu_provider::data_marker!(
203     /// `SentenceBreakValueToLongNameV1`
204     SentenceBreakValueToLongNameV1,
205     PropertyEnumToValueNameLinearMap<'static>,
206     is_singleton = true
207 );
208 icu_provider::data_marker!(
209     /// `SentenceBreakValueToShortNameV1`
210     SentenceBreakValueToShortNameV1,
211     PropertyEnumToValueNameLinearMap<'static>,
212     is_singleton = true
213 );
214 icu_provider::data_marker!(
215     /// `WordBreakValueToLongNameV1`
216     WordBreakValueToLongNameV1,
217     PropertyEnumToValueNameLinearMap<'static>,
218     is_singleton = true
219 );
220 icu_provider::data_marker!(
221     /// `WordBreakValueToShortNameV1`
222     WordBreakValueToShortNameV1,
223     PropertyEnumToValueNameLinearMap<'static>,
224     is_singleton = true
225 );
226 icu_provider::data_marker!(
227     /// `CanonicalCombiningClassValueToLongNameV1`
228     CanonicalCombiningClassValueToLongNameV1,
229     PropertyEnumToValueNameSparseMap<'static>,
230     is_singleton = true,
231 );
232 icu_provider::data_marker!(
233     /// `CanonicalCombiningClassValueToShortNameV1`
234     CanonicalCombiningClassValueToShortNameV1,
235     PropertyEnumToValueNameSparseMap<'static>,
236     is_singleton = true,
237 );
238 icu_provider::data_marker!(
239     /// `ScriptValueToShortNameV1`
240     ScriptValueToShortNameV1,
241     PropertyScriptToIcuScriptMap<'static>,
242     is_singleton = true,
243 );
244 
245 /// A set of characters and strings which share a particular property value.
246 ///
247 /// <div class="stab unstable">
248 /// �� This code is considered unstable; it may change at any time, in breaking or non-breaking ways,
249 /// including in SemVer minor releases. While the serde representation of data structs is guaranteed
250 /// to be stable, their Rust representation might not be. Use with caution.
251 /// </div>
252 #[derive(Debug, Clone, PartialEq, yoke::Yokeable, zerofrom::ZeroFrom)]
253 #[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))]
254 #[cfg_attr(feature = "datagen", databake(path = icu_properties::provider::names))]
255 #[cfg_attr(feature = "serde", derive(serde::Deserialize))]
256 pub struct PropertyValueNameToEnumMap<'data> {
257     /// A map from names to their value discriminant
258     #[cfg_attr(feature = "serde", serde(borrow))]
259     pub map: ZeroTrieSimpleAscii<ZeroVec<'data, u8>>,
260 }
261 
262 icu_provider::data_struct!(
263     PropertyValueNameToEnumMap<'_>,
264     #[cfg(feature = "datagen")]
265 );
266 
267 /// A mapping of property values to their names. A single instance of this map will only cover
268 /// either long or short names, determined whilst loading data.
269 ///
270 /// <div class="stab unstable">
271 /// �� This code is considered unstable; it may change at any time, in breaking or non-breaking ways,
272 /// including in SemVer minor releases. While the serde representation of data structs is guaranteed
273 /// to be stable, their Rust representation might not be. Use with caution.
274 /// </div>
275 #[derive(Debug, Clone, PartialEq, yoke::Yokeable, zerofrom::ZeroFrom)]
276 #[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))]
277 #[cfg_attr(feature = "datagen", databake(path = icu_properties::provider::names))]
278 #[cfg_attr(feature = "serde", derive(serde::Deserialize))]
279 #[yoke(prove_covariance_manually)]
280 pub struct PropertyEnumToValueNameSparseMap<'data> {
281     /// A map from the value discriminant to the names
282     #[cfg_attr(feature = "serde", serde(borrow))]
283     pub map: ZeroMap<'data, u16, str>,
284 }
285 
286 icu_provider::data_struct!(
287     PropertyEnumToValueNameSparseMap<'_>,
288     #[cfg(feature = "datagen")]
289 );
290 
291 /// A mapping of property values to their names. A single instance of this map will only cover
292 /// either long or short names, determined whilst loading data.
293 ///
294 /// <div class="stab unstable">
295 /// �� This code is considered unstable; it may change at any time, in breaking or non-breaking ways,
296 /// including in SemVer minor releases. While the serde representation of data structs is guaranteed
297 /// to be stable, their Rust representation might not be. Use with caution.
298 /// </div>
299 #[derive(Debug, Clone, PartialEq, yoke::Yokeable, zerofrom::ZeroFrom)]
300 #[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))]
301 #[cfg_attr(feature = "datagen", databake(path = icu_properties::provider::names))]
302 #[cfg_attr(feature = "serde", derive(serde::Deserialize))]
303 #[yoke(prove_covariance_manually)]
304 pub struct PropertyEnumToValueNameLinearMap<'data> {
305     /// A map from the value discriminant (the index) to the names, for mostly
306     /// contiguous data. Empty strings count as missing.
307     #[cfg_attr(feature = "serde", serde(borrow))]
308     pub map: VarZeroVec<'data, str>,
309 }
310 
311 icu_provider::data_struct!(
312     PropertyEnumToValueNameLinearMap<'_>,
313     #[cfg(feature = "datagen")]
314 );
315 
316 /// A mapping of property values to their names. A single instance of this map will only cover
317 /// either long or short names, determined whilst loading data.
318 ///
319 /// <div class="stab unstable">
320 /// �� This code is considered unstable; it may change at any time, in breaking or non-breaking ways,
321 /// including in SemVer minor releases. While the serde representation of data structs is guaranteed
322 /// to be stable, their Rust representation might not be. Use with caution.
323 /// </div>
324 #[derive(Debug, Clone, PartialEq, yoke::Yokeable, zerofrom::ZeroFrom)]
325 #[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))]
326 #[cfg_attr(feature = "datagen", databake(path = icu_properties::provider::names))]
327 #[cfg_attr(feature = "serde", derive(serde::Deserialize))]
328 #[yoke(prove_covariance_manually)]
329 pub struct PropertyScriptToIcuScriptMap<'data> {
330     /// A map from the value discriminant (the index) to the names, for mostly
331     /// contiguous data. Empty strings count as missing.
332     #[cfg_attr(feature = "serde", serde(borrow))]
333     pub map: ZeroVec<'data, NichedOption<Script, 4>>,
334 }
335 
336 icu_provider::data_struct!(
337     PropertyScriptToIcuScriptMap<'_>,
338     #[cfg(feature = "datagen")]
339 );
340