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