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