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