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::*;
17
18use zerotrie::ZeroTrieSimpleAscii;
19use zerovec::ule::NichedOption;
20use zerovec::{VarZeroVec, ZeroMap, 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);
244icu_provider::data_marker!(
245    /// `PropertyNameLongCanonicalCombiningClassV1`
246    PropertyNameLongCanonicalCombiningClassV1,
247    PropertyEnumToValueNameSparseMap<'static>,
248    is_singleton = true,
249);
250icu_provider::data_marker!(
251    /// `PropertyNameShortCanonicalCombiningClassV1`
252    PropertyNameShortCanonicalCombiningClassV1,
253    PropertyEnumToValueNameSparseMap<'static>,
254    is_singleton = true,
255);
256icu_provider::data_marker!(
257    /// `PropertyNameShortScriptV1`
258    PropertyNameShortScriptV1,
259    PropertyScriptToIcuScriptMap<'static>,
260    is_singleton = true,
261);
262
263/// A set of characters and strings which share a particular property value.
264///
265/// <div class="stab unstable">
266/// 🚧 This code is considered unstable; it may change at any time, in breaking or non-breaking ways,
267/// including in SemVer minor releases. While the serde representation of data structs is guaranteed
268/// to be stable, their Rust representation might not be. Use with caution.
269/// </div>
270#[derive(Debug, Clone, PartialEq, yoke::Yokeable, zerofrom::ZeroFrom)]
271#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))]
272#[cfg_attr(feature = "datagen", databake(path = icu_properties::provider::names))]
273#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
274pub struct PropertyValueNameToEnumMap<'data> {
275    /// A map from names to their value discriminant
276    #[cfg_attr(feature = "serde", serde(borrow))]
277    pub map: ZeroTrieSimpleAscii<ZeroVec<'data, u8>>,
278}
279
280icu_provider::data_struct!(
281    PropertyValueNameToEnumMap<'_>,
282    #[cfg(feature = "datagen")]
283);
284
285/// A mapping of property values to their names. A single instance of this map will only cover
286/// either long or short names, determined whilst loading data.
287///
288/// <div class="stab unstable">
289/// 🚧 This code is considered unstable; it may change at any time, in breaking or non-breaking ways,
290/// including in SemVer minor releases. While the serde representation of data structs is guaranteed
291/// to be stable, their Rust representation might not be. Use with caution.
292/// </div>
293#[derive(Debug, Clone, PartialEq, yoke::Yokeable, zerofrom::ZeroFrom)]
294#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))]
295#[cfg_attr(feature = "datagen", databake(path = icu_properties::provider::names))]
296#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
297#[yoke(prove_covariance_manually)]
298pub struct PropertyEnumToValueNameSparseMap<'data> {
299    /// A map from the value discriminant to the names
300    #[cfg_attr(feature = "serde", serde(borrow))]
301    pub map: ZeroMap<'data, u16, str>,
302}
303
304icu_provider::data_struct!(
305    PropertyEnumToValueNameSparseMap<'_>,
306    #[cfg(feature = "datagen")]
307);
308
309/// A mapping of property values to their names. A single instance of this map will only cover
310/// either long or short names, determined whilst loading data.
311///
312/// <div class="stab unstable">
313/// 🚧 This code is considered unstable; it may change at any time, in breaking or non-breaking ways,
314/// including in SemVer minor releases. While the serde representation of data structs is guaranteed
315/// to be stable, their Rust representation might not be. Use with caution.
316/// </div>
317#[derive(Debug, Clone, PartialEq, yoke::Yokeable, zerofrom::ZeroFrom)]
318#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))]
319#[cfg_attr(feature = "datagen", databake(path = icu_properties::provider::names))]
320#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
321#[yoke(prove_covariance_manually)]
322pub struct PropertyEnumToValueNameLinearMap<'data> {
323    /// A map from the value discriminant (the index) to the names, for mostly
324    /// contiguous data. Empty strings count as missing.
325    #[cfg_attr(feature = "serde", serde(borrow))]
326    pub map: VarZeroVec<'data, str>,
327}
328
329icu_provider::data_struct!(
330    PropertyEnumToValueNameLinearMap<'_>,
331    #[cfg(feature = "datagen")]
332);
333
334/// A mapping of property values to their names. A single instance of this map will only cover
335/// either long or short names, determined whilst loading data.
336///
337/// <div class="stab unstable">
338/// 🚧 This code is considered unstable; it may change at any time, in breaking or non-breaking ways,
339/// including in SemVer minor releases. While the serde representation of data structs is guaranteed
340/// to be stable, their Rust representation might not be. Use with caution.
341/// </div>
342#[derive(Debug, Clone, PartialEq, yoke::Yokeable, zerofrom::ZeroFrom)]
343#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))]
344#[cfg_attr(feature = "datagen", databake(path = icu_properties::provider::names))]
345#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
346#[yoke(prove_covariance_manually)]
347pub struct PropertyScriptToIcuScriptMap<'data> {
348    /// A map from the value discriminant (the index) to the names, for mostly
349    /// contiguous data. Empty strings count as missing.
350    #[cfg_attr(feature = "serde", serde(borrow))]
351    pub map: ZeroVec<'data, NichedOption<Script, 4>>,
352}
353
354icu_provider::data_struct!(
355    PropertyScriptToIcuScriptMap<'_>,
356    #[cfg(feature = "datagen")]
357);