icu_provider_source/properties/
uprops_serde.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// This file is part of ICU4X. For terms of use, please see the file
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

use icu::collections::codepointtrie::toml::CodePointTrieToml;

pub(crate) mod binary {
    #[derive(serde::Deserialize)]
    pub(crate) struct BinaryProperty {
        #[serde(rename = "long_name")]
        pub(crate) _long_name: String,
        #[serde(skip)]
        #[serde(rename = "short_name")]
        pub(crate) _short_name: String,
        pub(crate) ranges: Vec<(u32, u32)>,
        pub(crate) strings: Option<Vec<String>>,
    }

    #[derive(serde::Deserialize)]
    pub(crate) struct Main {
        #[serde(default)]
        pub(crate) binary_property: Vec<BinaryProperty>,
    }
}

#[derive(serde::Deserialize)]
pub(crate) struct PropertyValue {
    pub(crate) discr: u32,
    pub(crate) long: String,
    pub(crate) short: Option<String>,
    #[serde(default)]
    pub(crate) aliases: Vec<String>,
}

pub(crate) mod enumerated {
    #[derive(serde::Deserialize)]
    pub(crate) struct EnumeratedPropertyMapRange {
        #[serde(rename = "a")]
        pub(crate) _a: u32,
        #[serde(rename = "b")]
        pub(crate) _b: u32,
        #[serde(rename = "v")]
        pub(crate) _v: u32,
        #[serde(rename = "name")]
        pub(crate) _name: String,
    }

    #[derive(serde::Deserialize)]
    pub(crate) struct EnumeratedPropertyMap {
        #[serde(rename = "long_name")]
        pub(crate) _long_name: String,
        #[serde(rename = "short_name")]
        pub(crate) _short_name: String,
        pub(crate) values: Vec<super::PropertyValue>,
        #[serde(rename = "ranges")]
        pub(crate) _ranges: Vec<EnumeratedPropertyMapRange>,
        pub(crate) code_point_trie: super::CodePointTrieToml,
    }

    #[derive(serde::Deserialize)]
    pub(crate) struct Main {
        #[serde(default)]
        pub(crate) enum_property: Vec<EnumeratedPropertyMap>,
    }
}

pub(crate) mod code_point_prop {
    #[derive(serde::Deserialize)]
    pub(crate) struct CodePointPropertyMapRange {
        #[serde(rename = "a")]
        pub(crate) _a: u32,
        #[serde(rename = "b")]
        pub(crate) _b: u32,
        #[serde(rename = "v")]
        pub(crate) _v: u32,
    }

    #[derive(serde::Deserialize)]
    pub(crate) struct CodePointPropertyMap {
        #[serde(rename = "long_name")]
        pub(crate) _long_name: String,
        #[serde(rename = "short_name")]
        pub(crate) _short_name: String,
        #[serde(rename = "ranges")]
        pub(crate) _ranges: Vec<CodePointPropertyMapRange>,
        #[cfg(any(feature = "use_wasm", feature = "use_icu4c"))]
        pub(crate) code_point_trie: super::CodePointTrieToml,
    }

    #[derive(serde::Deserialize)]
    pub(crate) struct Main {
        // TODO: update icuexportdata to print a different TOML header than "enum_property"
        #[serde(default)]
        #[cfg(any(feature = "use_wasm", feature = "use_icu4c"))]
        pub(crate) enum_property: Vec<CodePointPropertyMap>,
    }
}

pub(crate) mod mask {
    #[derive(serde::Deserialize)]
    pub(crate) struct MaskPropertyMap {
        #[serde(rename = "long_name")]
        pub(crate) _long_name: String,
        #[serde(rename = "short_name")]
        pub(crate) _short_name: String,
        #[serde(rename = "mask_for")]
        pub(crate) _mask_for: String,
        pub(crate) values: Vec<super::PropertyValue>,
    }

    #[derive(serde::Deserialize)]
    pub(crate) struct Main {
        #[serde(default)]
        pub(crate) mask_property: Vec<MaskPropertyMap>,
    }
}

pub(crate) mod script_extensions {
    use super::CodePointTrieToml;

    #[derive(serde::Deserialize)]
    pub(crate) struct ScriptWithExtensionsPropertyV1Property {
        #[serde(rename = "long_name")]
        pub(crate) _long_name: String,
        #[serde(rename = "short_name")]
        pub(crate) _short_name: String,
        pub(crate) script_code_array: Vec<Vec<u16>>,
        pub(crate) code_point_trie: CodePointTrieToml,
    }

    #[derive(serde::Deserialize)]
    pub(crate) struct Main {
        #[serde(default)]
        pub(crate) script_extensions: Vec<ScriptWithExtensionsPropertyV1Property>,
    }
}