xmpp_parsers/mood.rs
1// Copyright (c) 2017 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7use xso::{AsXml, FromXml};
8
9use crate::ns;
10
11/// Enum representing all of the possible values of the XEP-0107 moods.
12#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
13#[xml(namespace = ns::MOOD, exhaustive)]
14pub enum MoodEnum {
15 /// Impressed with fear or apprehension; in fear; apprehensive.
16 #[xml(name = "afraid")]
17 Afraid,
18
19 /// Astonished; confounded with fear, surprise or wonder.
20 #[xml(name = "amazed")]
21 Amazed,
22
23 /// Inclined to love; having a propensity to love, or to sexual enjoyment; loving, fond, affectionate, passionate, lustful, sexual, etc.
24 #[xml(name = "amorous")]
25 Amorous,
26
27 /// Displaying or feeling anger, i.e., a strong feeling of displeasure, hostility or antagonism towards someone or something, usually combined with an urge to harm.
28 #[xml(name = "angry")]
29 Angry,
30
31 /// To be disturbed or irritated, especially by continued or repeated acts.
32 #[xml(name = "annoyed")]
33 Annoyed,
34
35 /// Full of anxiety or disquietude; greatly concerned or solicitous, esp. respecting something future or unknown; being in painful suspense.
36 #[xml(name = "anxious")]
37 Anxious,
38
39 /// To be stimulated in one's feelings, especially to be sexually stimulated.
40 #[xml(name = "aroused")]
41 Aroused,
42
43 /// Feeling shame or guilt.
44 #[xml(name = "ashamed")]
45 Ashamed,
46
47 /// Suffering from boredom; uninterested, without attention.
48 #[xml(name = "bored")]
49 Bored,
50
51 /// Strong in the face of fear; courageous.
52 #[xml(name = "brave")]
53 Brave,
54
55 /// Peaceful, quiet.
56 #[xml(name = "calm")]
57 Calm,
58
59 /// Taking care or caution; tentative.
60 #[xml(name = "cautious")]
61 Cautious,
62
63 /// Feeling the sensation of coldness, especially to the point of discomfort.
64 #[xml(name = "cold")]
65 Cold,
66
67 /// Feeling very sure of or positive about something, especially about one's own capabilities.
68 #[xml(name = "confident")]
69 Confident,
70
71 /// Chaotic, jumbled or muddled.
72 #[xml(name = "confused")]
73 Confused,
74
75 /// Feeling introspective or thoughtful.
76 #[xml(name = "contemplative")]
77 Contemplative,
78
79 /// Pleased at the satisfaction of a want or desire; satisfied.
80 #[xml(name = "contented")]
81 Contented,
82
83 /// Grouchy, irritable; easily upset.
84 #[xml(name = "cranky")]
85 Cranky,
86
87 /// Feeling out of control; feeling overly excited or enthusiastic.
88 #[xml(name = "crazy")]
89 Crazy,
90
91 /// Feeling original, expressive, or imaginative.
92 #[xml(name = "creative")]
93 Creative,
94
95 /// Inquisitive; tending to ask questions, investigate, or explore.
96 #[xml(name = "curious")]
97 Curious,
98
99 /// Feeling sad and dispirited.
100 #[xml(name = "dejected")]
101 Dejected,
102
103 /// Severely despondent and unhappy.
104 #[xml(name = "depressed")]
105 Depressed,
106
107 /// Defeated of expectation or hope; let down.
108 #[xml(name = "disappointed")]
109 Disappointed,
110
111 /// Filled with disgust; irritated and out of patience.
112 #[xml(name = "disgusted")]
113 Disgusted,
114
115 /// Feeling a sudden or complete loss of courage in the face of trouble or danger.
116 #[xml(name = "dismayed")]
117 Dismayed,
118
119 /// Having one's attention diverted; preoccupied.
120 #[xml(name = "distracted")]
121 Distracted,
122
123 /// Having a feeling of shameful discomfort.
124 #[xml(name = "embarrassed")]
125 Embarrassed,
126
127 /// Feeling pain by the excellence or good fortune of another.
128 #[xml(name = "envious")]
129 Envious,
130
131 /// Having great enthusiasm.
132 #[xml(name = "excited")]
133 Excited,
134
135 /// In the mood for flirting.
136 #[xml(name = "flirtatious")]
137 Flirtatious,
138
139 /// Suffering from frustration; dissatisfied, agitated, or discontented because one is unable to perform an action or fulfill a desire.
140 #[xml(name = "frustrated")]
141 Frustrated,
142
143 /// Feeling appreciation or thanks.
144 #[xml(name = "grateful")]
145 Grateful,
146
147 /// Feeling very sad about something, especially something lost; mournful; sorrowful.
148 #[xml(name = "grieving")]
149 Grieving,
150
151 /// Unhappy and irritable.
152 #[xml(name = "grumpy")]
153 Grumpy,
154
155 /// Feeling responsible for wrongdoing; feeling blameworthy.
156 #[xml(name = "guilty")]
157 Guilty,
158
159 /// Experiencing the effect of favourable fortune; having the feeling arising from the consciousness of well-being or of enjoyment; enjoying good of any kind, as peace, tranquillity, comfort; contented; joyous.
160 #[xml(name = "happy")]
161 Happy,
162
163 /// Having a positive feeling, belief, or expectation that something wished for can or will happen.
164 #[xml(name = "hopeful")]
165 Hopeful,
166
167 /// Feeling the sensation of heat, especially to the point of discomfort.
168 #[xml(name = "hot")]
169 Hot,
170
171 /// Having or showing a modest or low estimate of one's own importance; feeling lowered in dignity or importance.
172 #[xml(name = "humbled")]
173 Humbled,
174
175 /// Feeling deprived of dignity or self-respect.
176 #[xml(name = "humiliated")]
177 Humiliated,
178
179 /// Having a physical need for food.
180 #[xml(name = "hungry")]
181 Hungry,
182
183 /// Wounded, injured, or pained, whether physically or emotionally.
184 #[xml(name = "hurt")]
185 Hurt,
186
187 /// Favourably affected by something or someone.
188 #[xml(name = "impressed")]
189 Impressed,
190
191 /// Feeling amazement at something or someone; or feeling a combination of fear and reverence.
192 #[xml(name = "in_awe")]
193 InAwe,
194
195 /// Feeling strong affection, care, liking, or attraction..
196 #[xml(name = "in_love")]
197 InLove,
198
199 /// Showing anger or indignation, especially at something unjust or wrong.
200 #[xml(name = "indignant")]
201 Indignant,
202
203 /// Showing great attention to something or someone; having or showing interest.
204 #[xml(name = "interested")]
205 Interested,
206
207 /// Under the influence of alcohol; drunk.
208 #[xml(name = "intoxicated")]
209 Intoxicated,
210
211 /// Feeling as if one cannot be defeated, overcome or denied.
212 #[xml(name = "invincible")]
213 Invincible,
214
215 /// Fearful of being replaced in position or affection.
216 #[xml(name = "jealous")]
217 Jealous,
218
219 /// Feeling isolated, empty, or abandoned.
220 #[xml(name = "lonely")]
221 Lonely,
222
223 /// Unable to find one's way, either physically or emotionally.
224 #[xml(name = "lost")]
225 Lost,
226
227 /// Feeling as if one will be favored by luck.
228 #[xml(name = "lucky")]
229 Lucky,
230
231 /// Causing or intending to cause intentional harm; bearing ill will towards another; cruel; malicious.
232 #[xml(name = "mean")]
233 Mean,
234
235 /// Given to sudden or frequent changes of mind or feeling; temperamental.
236 #[xml(name = "moody")]
237 Moody,
238
239 /// Easily agitated or alarmed; apprehensive or anxious.
240 #[xml(name = "nervous")]
241 Nervous,
242
243 /// Not having a strong mood or emotional state.
244 #[xml(name = "neutral")]
245 Neutral,
246
247 /// Feeling emotionally hurt, displeased, or insulted.
248 #[xml(name = "offended")]
249 Offended,
250
251 /// Feeling resentful anger caused by an extremely violent or vicious attack, or by an offensive, immoral, or indecent act.
252 #[xml(name = "outraged")]
253 Outraged,
254
255 /// Interested in play; fun, recreational, unserious, lighthearted; joking, silly.
256 #[xml(name = "playful")]
257 Playful,
258
259 /// Feeling a sense of one's own worth or accomplishment.
260 #[xml(name = "proud")]
261 Proud,
262
263 /// Having an easy-going mood; not stressed; calm.
264 #[xml(name = "relaxed")]
265 Relaxed,
266
267 /// Feeling uplifted because of the removal of stress or discomfort.
268 #[xml(name = "relieved")]
269 Relieved,
270
271 /// Feeling regret or sadness for doing something wrong.
272 #[xml(name = "remorseful")]
273 Remorseful,
274
275 /// Without rest; unable to be still or quiet; uneasy; continually moving.
276 #[xml(name = "restless")]
277 Restless,
278
279 /// Feeling sorrow; sorrowful, mournful.
280 #[xml(name = "sad")]
281 Sad,
282
283 /// Mocking and ironical.
284 #[xml(name = "sarcastic")]
285 Sarcastic,
286
287 /// Pleased at the fulfillment of a need or desire.
288 #[xml(name = "satisfied")]
289 Satisfied,
290
291 /// Without humor or expression of happiness; grave in manner or disposition; earnest; thoughtful; solemn.
292 #[xml(name = "serious")]
293 Serious,
294
295 /// Surprised, startled, confused, or taken aback.
296 #[xml(name = "shocked")]
297 Shocked,
298
299 /// Feeling easily frightened or scared; timid; reserved or coy.
300 #[xml(name = "shy")]
301 Shy,
302
303 /// Feeling in poor health; ill.
304 #[xml(name = "sick")]
305 Sick,
306
307 /// Feeling the need for sleep.
308 #[xml(name = "sleepy")]
309 Sleepy,
310
311 /// Acting without planning; natural; impulsive.
312 #[xml(name = "spontaneous")]
313 Spontaneous,
314
315 /// Suffering emotional pressure.
316 #[xml(name = "stressed")]
317 Stressed,
318
319 /// Capable of producing great physical force; or, emotionally forceful, able, determined, unyielding.
320 #[xml(name = "strong")]
321 Strong,
322
323 /// Experiencing a feeling caused by something unexpected.
324 #[xml(name = "surprised")]
325 Surprised,
326
327 /// Showing appreciation or gratitude.
328 #[xml(name = "thankful")]
329 Thankful,
330
331 /// Feeling the need to drink.
332 #[xml(name = "thirsty")]
333 Thirsty,
334
335 /// In need of rest or sleep.
336 #[xml(name = "tired")]
337 Tired,
338
339 /// [Feeling any emotion not defined here.]
340 #[xml(name = "undefined")]
341 Undefined,
342
343 /// Lacking in force or ability, either physical or emotional.
344 #[xml(name = "weak")]
345 Weak,
346
347 /// Thinking about unpleasant things that have happened or that might happen; feeling afraid and unhappy.
348 #[xml(name = "worried")]
349 Worried,
350}
351
352generate_elem_id!(
353 /// Free-form text description of the mood.
354 Text,
355 "text",
356 MOOD
357);
358
359#[cfg(test)]
360mod tests {
361 use super::*;
362 use minidom::Element;
363
364 #[cfg(target_pointer_width = "32")]
365 #[test]
366 fn test_size() {
367 assert_size!(MoodEnum, 1);
368 assert_size!(Text, 12);
369 }
370
371 #[cfg(target_pointer_width = "64")]
372 #[test]
373 fn test_size() {
374 assert_size!(MoodEnum, 1);
375 assert_size!(Text, 24);
376 }
377
378 #[test]
379 fn test_simple() {
380 let elem: Element = "<happy xmlns='http://jabber.org/protocol/mood'/>"
381 .parse()
382 .unwrap();
383 let mood = MoodEnum::try_from(elem).unwrap();
384 assert_eq!(mood, MoodEnum::Happy);
385 }
386
387 #[test]
388 fn test_text() {
389 let elem: Element = "<text xmlns='http://jabber.org/protocol/mood'>Yay!</text>"
390 .parse()
391 .unwrap();
392 let elem2 = elem.clone();
393 let text = Text::try_from(elem).unwrap();
394 assert_eq!(text.0, String::from("Yay!"));
395
396 let elem3 = text.into();
397 assert_eq!(elem2, elem3);
398 }
399}