Skip to main content

icu_properties/provider/
names.rs

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
15use icu_locale_core::subtags::Script;
16use icu_provider::prelude::{yoke, zerofrom};
17
18use zerotrie::ZeroTrieSimpleAscii;
19use zerovec::ule::NichedOption;
20use zerovec::{VarZeroVec, ZeroVec};
21
22icu_provider::data_marker!(
23    /// `PropertyNameParseBidiClassV1`
24    PropertyNameParseBidiClassV1,
25    PropertyValueNameToEnumMap<'static>,
26    is_singleton = true
27);
28icu_provider::data_marker!(
29    /// `PropertyNameParseBlockV1`
30    PropertyNameParseBlockV1,
31    PropertyValueNameToEnumMap<'static>,
32    is_singleton = true
33);
34icu_provider::data_marker!(
35    /// `PropertyNameParseCanonicalCombiningClassV1`
36    PropertyNameParseCanonicalCombiningClassV1,
37    PropertyValueNameToEnumMap<'static>,
38    is_singleton = true
39);
40icu_provider::data_marker!(
41    /// `PropertyNameParseEastAsianWidthV1`
42    PropertyNameParseEastAsianWidthV1,
43    PropertyValueNameToEnumMap<'static>,
44    is_singleton = true
45);
46icu_provider::data_marker!(
47    /// `PropertyNameParseGeneralCategoryMaskV1`
48    PropertyNameParseGeneralCategoryMaskV1,
49    PropertyValueNameToEnumMap<'static>,
50    is_singleton = true
51);
52icu_provider::data_marker!(
53    /// `PropertyNameParseGeneralCategoryV1`
54    PropertyNameParseGeneralCategoryV1,
55    PropertyValueNameToEnumMap<'static>,
56    is_singleton = true
57);
58icu_provider::data_marker!(
59    /// `PropertyNameParseGraphemeClusterBreakV1`
60    PropertyNameParseGraphemeClusterBreakV1,
61    PropertyValueNameToEnumMap<'static>,
62    is_singleton = true
63);
64icu_provider::data_marker!(
65    /// `PropertyNameParseHangulSyllableTypeV1`
66    PropertyNameParseHangulSyllableTypeV1,
67    PropertyValueNameToEnumMap<'static>,
68    is_singleton = true
69);
70icu_provider::data_marker!(
71    /// `PropertyNameParseIndicSyllabicCategoryV1`
72    PropertyNameParseIndicSyllabicCategoryV1,
73    PropertyValueNameToEnumMap<'static>,
74    is_singleton = true
75);
76icu_provider::data_marker!(
77    /// `PropertyNameParseIndicConjunctBreakV1`
78    PropertyNameParseIndicConjunctBreakV1,
79    PropertyValueNameToEnumMap<'static>,
80    is_singleton = true
81);
82icu_provider::data_marker!(
83    /// `PropertyNameParseJoiningGroupV1`
84    PropertyNameParseJoiningGroupV1,
85    PropertyValueNameToEnumMap<'static>,
86    is_singleton = true
87);
88icu_provider::data_marker!(
89    /// `PropertyNameParseJoiningTypeV1`
90    PropertyNameParseJoiningTypeV1,
91    PropertyValueNameToEnumMap<'static>,
92    is_singleton = true
93);
94icu_provider::data_marker!(
95    /// `PropertyNameParseLineBreakV1`
96    PropertyNameParseLineBreakV1,
97    PropertyValueNameToEnumMap<'static>,
98    is_singleton = true
99);
100icu_provider::data_marker!(
101    /// `PropertyNameParseNumericTypeV1`
102    PropertyNameParseNumericTypeV1,
103    PropertyValueNameToEnumMap<'static>,
104    is_singleton = true
105);
106icu_provider::data_marker!(
107    /// `PropertyNameParseScriptV1`
108    PropertyNameParseScriptV1,
109    PropertyValueNameToEnumMap<'static>,
110    is_singleton = true
111);
112icu_provider::data_marker!(
113    /// `PropertyNameParseSentenceBreakV1`
114    PropertyNameParseSentenceBreakV1,
115    PropertyValueNameToEnumMap<'static>,
116    is_singleton = true
117);
118icu_provider::data_marker!(
119    /// `PropertyNameParseVerticalOrientationV1`
120    PropertyNameParseVerticalOrientationV1,
121    PropertyValueNameToEnumMap<'static>,
122    is_singleton = true
123);
124icu_provider::data_marker!(
125    /// `PropertyNameParseWordBreakV1`
126    PropertyNameParseWordBreakV1,
127    PropertyValueNameToEnumMap<'static>,
128    is_singleton = true
129);
130icu_provider::data_marker!(
131    /// `PropertyNameLongBidiClassV1`
132    PropertyNameLongBidiClassV1,
133    PropertyEnumToValueNameLinearMap<'static>,
134    is_singleton = true
135);
136icu_provider::data_marker!(
137    /// `PropertyNameShortBidiClassV1`
138    PropertyNameShortBidiClassV1,
139    PropertyEnumToValueNameLinearMap<'static>,
140    is_singleton = true
141);
142icu_provider::data_marker!(
143    /// `PropertyNameLongBlockV1`
144    PropertyNameLongBlockV1,
145    PropertyEnumToValueNameLinearMap<'static>,
146    is_singleton = true
147);
148icu_provider::data_marker!(
149    /// `PropertyNameShortBlockV1`
150    PropertyNameShortBlockV1,
151    PropertyEnumToValueNameLinearMap<'static>,
152    is_singleton = true
153);
154icu_provider::data_marker!(
155    /// `PropertyNameLongEastAsianWidthV1`
156    PropertyNameLongEastAsianWidthV1,
157    PropertyEnumToValueNameLinearMap<'static>,
158    is_singleton = true
159);
160icu_provider::data_marker!(
161    /// `PropertyNameShortEastAsianWidthV1`
162    PropertyNameShortEastAsianWidthV1,
163    PropertyEnumToValueNameLinearMap<'static>,
164    is_singleton = true
165);
166icu_provider::data_marker!(
167    /// `PropertyNameLongGeneralCategoryV1`
168    PropertyNameLongGeneralCategoryV1,
169    PropertyEnumToValueNameLinearMap<'static>,
170    is_singleton = true
171);
172icu_provider::data_marker!(
173    /// `PropertyNameShortGeneralCategoryV1`
174    PropertyNameShortGeneralCategoryV1,
175    PropertyEnumToValueNameLinearMap<'static>,
176    is_singleton = true
177);
178icu_provider::data_marker!(
179    /// `PropertyNameLongGraphemeClusterBreakV1`
180    PropertyNameLongGraphemeClusterBreakV1,
181    PropertyEnumToValueNameLinearMap<'static>,
182    is_singleton = true
183);
184icu_provider::data_marker!(
185    /// `PropertyNameShortGraphemeClusterBreakV1`
186    PropertyNameShortGraphemeClusterBreakV1,
187    PropertyEnumToValueNameLinearMap<'static>,
188    is_singleton = true
189);
190icu_provider::data_marker!(
191    /// `PropertyNameLongHangulSyllableTypeV1`
192    PropertyNameLongHangulSyllableTypeV1,
193    PropertyEnumToValueNameLinearMap<'static>,
194    is_singleton = true
195);
196icu_provider::data_marker!(
197    /// `PropertyNameShortHangulSyllableTypeV1`
198    PropertyNameShortHangulSyllableTypeV1,
199    PropertyEnumToValueNameLinearMap<'static>,
200    is_singleton = true
201);
202icu_provider::data_marker!(
203    /// `PropertyNameLongIndicSyllabicCategoryV1`
204    PropertyNameLongIndicSyllabicCategoryV1,
205    PropertyEnumToValueNameLinearMap<'static>,
206    is_singleton = true
207);
208icu_provider::data_marker!(
209    /// `PropertyNameShortIndicSyllabicCategoryV1`
210    PropertyNameShortIndicSyllabicCategoryV1,
211    PropertyEnumToValueNameLinearMap<'static>,
212    is_singleton = true
213);
214icu_provider::data_marker!(
215    /// `PropertyNameLongIndicConjunctBreakV1`
216    PropertyNameLongIndicConjunctBreakV1,
217    PropertyEnumToValueNameLinearMap<'static>,
218    is_singleton = true
219);
220icu_provider::data_marker!(
221    /// `PropertyNameShortIndicConjunctBreakV1`
222    PropertyNameShortIndicConjunctBreakV1,
223    PropertyEnumToValueNameLinearMap<'static>,
224    is_singleton = true
225);
226icu_provider::data_marker!(
227    /// `PropertyNameLongJoiningGroupV1`
228    PropertyNameLongJoiningGroupV1,
229    PropertyEnumToValueNameLinearMap<'static>,
230    is_singleton = true
231);
232icu_provider::data_marker!(
233    /// `PropertyNameShortJoiningGroupV1`
234    PropertyNameShortJoiningGroupV1,
235    PropertyEnumToValueNameLinearMap<'static>,
236    is_singleton = true
237);
238icu_provider::data_marker!(
239    /// `PropertyNameLongJoiningTypeV1`
240    PropertyNameLongJoiningTypeV1,
241    PropertyEnumToValueNameLinearMap<'static>,
242    is_singleton = true
243);
244icu_provider::data_marker!(
245    /// `PropertyNameShortJoiningTypeV1`
246    PropertyNameShortJoiningTypeV1,
247    PropertyEnumToValueNameLinearMap<'static>,
248    is_singleton = true
249);
250icu_provider::data_marker!(
251    /// `PropertyNameLongLineBreakV1`
252    PropertyNameLongLineBreakV1,
253    PropertyEnumToValueNameLinearMap<'static>,
254    is_singleton = true
255);
256icu_provider::data_marker!(
257    /// `PropertyNameLongNumericTypeV1`
258    PropertyNameLongNumericTypeV1,
259    PropertyEnumToValueNameLinearMap<'static>,
260    is_singleton = true,
261);
262icu_provider::data_marker!(
263    /// `PropertyNameShortNumericTypeV1`
264    PropertyNameShortNumericTypeV1,
265    PropertyEnumToValueNameLinearMap<'static>,
266    is_singleton = true,
267);
268icu_provider::data_marker!(
269    /// `PropertyNameShortLineBreakV1`
270    PropertyNameShortLineBreakV1,
271    PropertyEnumToValueNameLinearMap<'static>,
272    is_singleton = true
273);
274icu_provider::data_marker!(
275    /// `PropertyNameLongScriptV1`
276    PropertyNameLongScriptV1,
277    PropertyEnumToValueNameLinearMap<'static>,
278    is_singleton = true
279);
280icu_provider::data_marker!(
281    /// `PropertyNameLongSentenceBreakV1`
282    PropertyNameLongSentenceBreakV1,
283    PropertyEnumToValueNameLinearMap<'static>,
284    is_singleton = true
285);
286icu_provider::data_marker!(
287    /// `PropertyNameShortSentenceBreakV1`
288    PropertyNameShortSentenceBreakV1,
289    PropertyEnumToValueNameLinearMap<'static>,
290    is_singleton = true
291);
292icu_provider::data_marker!(
293    /// `PropertyNameLongVerticalOrientationV1`
294    PropertyNameLongVerticalOrientationV1,
295    PropertyEnumToValueNameLinearMap<'static>,
296    is_singleton = true
297);
298icu_provider::data_marker!(
299    /// `PropertyNameShortVerticalOrientationV1`
300    PropertyNameShortVerticalOrientationV1,
301    PropertyEnumToValueNameLinearMap<'static>,
302    is_singleton = true
303);
304icu_provider::data_marker!(
305    /// `PropertyNameLongWordBreakV1`
306    PropertyNameLongWordBreakV1,
307    PropertyEnumToValueNameLinearMap<'static>,
308    is_singleton = true
309);
310icu_provider::data_marker!(
311    /// `PropertyNameShortWordBreakV1`
312    PropertyNameShortWordBreakV1,
313    PropertyEnumToValueNameLinearMap<'static>,
314    is_singleton = true
315);
316#[cfg(feature = "alloc")]
317icu_provider::data_marker!(
318    /// `PropertyNameLongCanonicalCombiningClassV1`
319    PropertyNameLongCanonicalCombiningClassV1,
320    PropertyEnumToValueNameSparseMap<'static>,
321    is_singleton = true,
322);
323#[cfg(feature = "alloc")]
324icu_provider::data_marker!(
325    /// `PropertyNameShortCanonicalCombiningClassV1`
326    PropertyNameShortCanonicalCombiningClassV1,
327    PropertyEnumToValueNameSparseMap<'static>,
328    is_singleton = true,
329);
330icu_provider::data_marker!(
331    /// `PropertyNameShortScriptV1`
332    PropertyNameShortScriptV1,
333    PropertyScriptToIcuScriptMap<'static>,
334    is_singleton = true,
335);
336
337/// A set of characters and strings which share a particular property value.
338///
339/// <div class="stab unstable">
340/// 🚧 This code is considered unstable; it may change at any time, in breaking or non-breaking ways,
341/// including in SemVer minor releases. While the serde representation of data structs is guaranteed
342/// to be stable, their Rust representation might not be. Use with caution.
343/// </div>
344#[derive(Debug, Clone, PartialEq, yoke::Yokeable, zerofrom::ZeroFrom)]
345#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))]
346#[cfg_attr(feature = "datagen", databake(path = icu_properties::provider::names))]
347#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
348pub struct PropertyValueNameToEnumMap<'data> {
349    /// A map from names to their value discriminant
350    #[cfg_attr(feature = "serde", serde(borrow))]
351    pub map: ZeroTrieSimpleAscii<ZeroVec<'data, u8>>,
352}
353
354icu_provider::data_struct!(
355    PropertyValueNameToEnumMap<'_>,
356    #[cfg(feature = "datagen")]
357);
358
359/// A mapping of property values to their names. A single instance of this map will only cover
360/// either long or short names, determined whilst loading data.
361///
362/// <div class="stab unstable">
363/// 🚧 This code is considered unstable; it may change at any time, in breaking or non-breaking ways,
364/// including in SemVer minor releases. While the serde representation of data structs is guaranteed
365/// to be stable, their Rust representation might not be. Use with caution.
366/// </div>
367#[derive(Debug, Clone, PartialEq, yoke::Yokeable, zerofrom::ZeroFrom)]
368#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))]
369#[cfg_attr(feature = "datagen", databake(path = icu_properties::provider::names))]
370#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
371#[yoke(prove_covariance_manually)]
372#[cfg(feature = "alloc")]
373pub struct PropertyEnumToValueNameSparseMap<'data> {
374    /// A map from the value discriminant to the names
375    #[cfg_attr(feature = "serde", serde(borrow))]
376    pub map: zerovec::ZeroMap<'data, u16, str>,
377}
378
379#[cfg(feature = "alloc")]
380icu_provider::data_struct!(
381    PropertyEnumToValueNameSparseMap<'_>,
382    #[cfg(feature = "datagen")]
383);
384
385/// A mapping of property values to their names. A single instance of this map will only cover
386/// either long or short names, determined whilst loading data.
387///
388/// <div class="stab unstable">
389/// 🚧 This code is considered unstable; it may change at any time, in breaking or non-breaking ways,
390/// including in SemVer minor releases. While the serde representation of data structs is guaranteed
391/// to be stable, their Rust representation might not be. Use with caution.
392/// </div>
393#[derive(Debug, Clone, PartialEq, yoke::Yokeable, zerofrom::ZeroFrom)]
394#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))]
395#[cfg_attr(feature = "datagen", databake(path = icu_properties::provider::names))]
396#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
397#[yoke(prove_covariance_manually)]
398pub struct PropertyEnumToValueNameLinearMap<'data> {
399    /// A map from the value discriminant (the index) to the names, for mostly
400    /// contiguous data. Empty strings count as missing.
401    #[cfg_attr(feature = "serde", serde(borrow))]
402    pub map: VarZeroVec<'data, str>,
403}
404
405icu_provider::data_struct!(
406    PropertyEnumToValueNameLinearMap<'_>,
407    #[cfg(feature = "datagen")]
408);
409
410/// A mapping of property values to their names. A single instance of this map will only cover
411/// either long or short names, determined whilst loading data.
412///
413/// <div class="stab unstable">
414/// 🚧 This code is considered unstable; it may change at any time, in breaking or non-breaking ways,
415/// including in SemVer minor releases. While the serde representation of data structs is guaranteed
416/// to be stable, their Rust representation might not be. Use with caution.
417/// </div>
418#[derive(Debug, Clone, PartialEq, yoke::Yokeable, zerofrom::ZeroFrom)]
419#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))]
420#[cfg_attr(feature = "datagen", databake(path = icu_properties::provider::names))]
421#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
422#[yoke(prove_covariance_manually)]
423pub struct PropertyScriptToIcuScriptMap<'data> {
424    /// A map from the value discriminant (the index) to the names, for mostly
425    /// contiguous data. Empty strings count as missing.
426    #[cfg_attr(feature = "serde", serde(borrow))]
427    pub map: ZeroVec<'data, NichedOption<Script, 4>>,
428}
429
430icu_provider::data_struct!(
431    PropertyScriptToIcuScriptMap<'_>,
432    #[cfg(feature = "datagen")]
433);