1use serde::Deserialize;
6
7#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Deserialize)]
8#[serde(rename_all = "lowercase")]
9pub enum Kind {
10 Consonant,
11 Vowel,
12 Symbol,
13}
14
15#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Deserialize)]
21#[serde(rename_all = "lowercase")]
22pub enum Form {
23 Consonant,
24 Vowel,
25 Any,
26}
27
28impl From<Form> for Kind {
29 fn from(form: Form) -> Kind {
30 match form {
31 Form::Consonant => Kind::Consonant,
32 Form::Vowel | Form::Any => Kind::Vowel,
34 }
35 }
36}
37
38impl Kind {
39 pub fn as_str(self) -> &'static str {
40 match self {
41 Kind::Consonant => "consonant",
42 Kind::Vowel => "vowel",
43 Kind::Symbol => "symbol",
44 }
45 }
46}
47
48#[derive(Debug, Clone, Deserialize)]
49pub struct Phone {
50 pub ipa: String,
51 pub talk: String,
52 pub xsampa: String,
53 pub simple: String,
54 pub form: Form,
55 pub place: Option<String>,
56 pub manner: Option<String>,
57 pub voicing: Option<String>,
58 pub height: Option<String>,
59 pub backness: Option<String>,
60 pub roundedness: Option<String>,
61 #[serde(default)]
62 pub provisional: bool,
63}
64
65#[derive(Debug, Clone, Deserialize)]
66#[serde(rename_all = "camelCase")]
67pub struct Attaches {
68 pub place: Option<Vec<String>>,
69 pub not_place: Option<Vec<String>>,
70 pub manner: Option<Vec<String>>,
71 pub voicing: Option<Vec<String>>,
72}
73
74#[derive(Debug, Clone, Deserialize)]
75pub struct Modifier {
76 pub ipa: String,
77 pub talk: String,
78 pub xsampa: String,
79 pub simple: String,
80 pub base: Form,
81 pub feature: String,
82 pub slot: String,
83 pub order: i64,
84 #[serde(default)]
85 pub prefix: bool,
86 pub attaches: Option<Attaches>,
87 #[serde(default)]
97 pub detail: bool,
98}
99
100#[derive(Debug, Clone, PartialEq, Eq)]
101pub struct Sound {
102 pub talk: String,
103 pub ipa: String,
104 pub simple: String,
105 pub machine: i64,
106 pub kind: Kind,
107 pub base: Option<&'static Phone>,
108 pub modifiers: Vec<&'static Modifier>,
109 pub pre: Vec<&'static Modifier>,
113 pub raw: bool,
114}
115
116impl PartialEq for Phone {
119 fn eq(&self, other: &Phone) -> bool {
120 std::ptr::eq(self, other)
121 }
122}
123
124impl Eq for Phone {}
125
126impl PartialEq for Modifier {
127 fn eq(&self, other: &Modifier) -> bool {
128 std::ptr::eq(self, other)
129 }
130}
131
132impl Eq for Modifier {}
133
134#[derive(Debug, Clone, PartialEq, Eq)]
136pub struct SymbolEntry {
137 pub talk: String,
138 pub ipa: String,
139 pub simple: String,
140}
141
142#[derive(Debug, Clone, PartialEq, Eq)]
144pub struct SoundInfo {
145 pub talk: String,
146 pub ipa: String,
147 pub simple: String,
148 pub kind: Kind,
149}
150
151pub const CODE_LIMIT: i64 = 0xff_ffff;
154
155pub const NO_CODE: i64 = -1;
158
159#[derive(Debug, Clone, Copy)]
162pub enum Unit {
163 Phone(&'static Phone),
164 Modifier(&'static Modifier),
165 Symbol(&'static SymbolEntry),
166}