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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
// Copyright (c) 2017 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

generate_element_enum!(
    /// Enum representing all of the possible values of the XEP-0107 moods.
    MoodEnum, "mood", MOOD, {
        /// Impressed with fear or apprehension; in fear; apprehensive.
        Afraid => "afraid",

        /// Astonished; confounded with fear, surprise or wonder.
        Amazed => "amazed",

        /// Inclined to love; having a propensity to love, or to sexual enjoyment; loving, fond, affectionate, passionate, lustful, sexual, etc.
        Amorous => "amorous",

        /// 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.
        Angry => "angry",

        /// To be disturbed or irritated, especially by continued or repeated acts.
        Annoyed => "annoyed",

        /// Full of anxiety or disquietude; greatly concerned or solicitous, esp. respecting something future or unknown; being in painful suspense.
        Anxious => "anxious",

        /// To be stimulated in one's feelings, especially to be sexually stimulated.
        Aroused => "aroused",

        /// Feeling shame or guilt.
        Ashamed => "ashamed",

        /// Suffering from boredom; uninterested, without attention.
        Bored => "bored",

        /// Strong in the face of fear; courageous.
        Brave => "brave",

        /// Peaceful, quiet.
        Calm => "calm",

        /// Taking care or caution; tentative.
        Cautious => "cautious",

        /// Feeling the sensation of coldness, especially to the point of discomfort.
        Cold => "cold",

        /// Feeling very sure of or positive about something, especially about one's own capabilities.
        Confident => "confident",

        /// Chaotic, jumbled or muddled.
        Confused => "confused",

        /// Feeling introspective or thoughtful.
        Contemplative => "contemplative",

        /// Pleased at the satisfaction of a want or desire; satisfied.
        Contented => "contented",

        /// Grouchy, irritable; easily upset.
        Cranky => "cranky",

        /// Feeling out of control; feeling overly excited or enthusiastic.
        Crazy => "crazy",

        /// Feeling original, expressive, or imaginative.
        Creative => "creative",

        /// Inquisitive; tending to ask questions, investigate, or explore.
        Curious => "curious",

        /// Feeling sad and dispirited.
        Dejected => "dejected",

        /// Severely despondent and unhappy.
        Depressed => "depressed",

        /// Defeated of expectation or hope; let down.
        Disappointed => "disappointed",

        /// Filled with disgust; irritated and out of patience.
        Disgusted => "disgusted",

        /// Feeling a sudden or complete loss of courage in the face of trouble or danger.
        Dismayed => "dismayed",

        /// Having one's attention diverted; preoccupied.
        Distracted => "distracted",

        /// Having a feeling of shameful discomfort.
        Embarrassed => "embarrassed",

        /// Feeling pain by the excellence or good fortune of another.
        Envious => "envious",

        /// Having great enthusiasm.
        Excited => "excited",

        /// In the mood for flirting.
        Flirtatious => "flirtatious",

        /// Suffering from frustration; dissatisfied, agitated, or discontented because one is unable to perform an action or fulfill a desire.
        Frustrated => "frustrated",

        /// Feeling appreciation or thanks.
        Grateful => "grateful",

        /// Feeling very sad about something, especially something lost; mournful; sorrowful.
        Grieving => "grieving",

        /// Unhappy and irritable.
        Grumpy => "grumpy",

        /// Feeling responsible for wrongdoing; feeling blameworthy.
        Guilty => "guilty",

        /// 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.
        Happy => "happy",

        /// Having a positive feeling, belief, or expectation that something wished for can or will happen.
        Hopeful => "hopeful",

        /// Feeling the sensation of heat, especially to the point of discomfort.
        Hot => "hot",

        /// Having or showing a modest or low estimate of one's own importance; feeling lowered in dignity or importance.
        Humbled => "humbled",

        /// Feeling deprived of dignity or self-respect.
        Humiliated => "humiliated",

        /// Having a physical need for food.
        Hungry => "hungry",

        /// Wounded, injured, or pained, whether physically or emotionally.
        Hurt => "hurt",

        /// Favourably affected by something or someone.
        Impressed => "impressed",

        /// Feeling amazement at something or someone; or feeling a combination of fear and reverence.
        InAwe => "in_awe",

        /// Feeling strong affection, care, liking, or attraction..
        InLove => "in_love",

        /// Showing anger or indignation, especially at something unjust or wrong.
        Indignant => "indignant",

        /// Showing great attention to something or someone; having or showing interest.
        Interested => "interested",

        /// Under the influence of alcohol; drunk.
        Intoxicated => "intoxicated",

        /// Feeling as if one cannot be defeated, overcome or denied.
        Invincible => "invincible",

        /// Fearful of being replaced in position or affection.
        Jealous => "jealous",

        /// Feeling isolated, empty, or abandoned.
        Lonely => "lonely",

        /// Unable to find one's way, either physically or emotionally.
        Lost => "lost",

        /// Feeling as if one will be favored by luck.
        Lucky => "lucky",

        /// Causing or intending to cause intentional harm; bearing ill will towards another; cruel; malicious.
        Mean => "mean",

        /// Given to sudden or frequent changes of mind or feeling; temperamental.
        Moody => "moody",

        /// Easily agitated or alarmed; apprehensive or anxious.
        Nervous => "nervous",

        /// Not having a strong mood or emotional state.
        Neutral => "neutral",

        /// Feeling emotionally hurt, displeased, or insulted.
        Offended => "offended",

        /// Feeling resentful anger caused by an extremely violent or vicious attack, or by an offensive, immoral, or indecent act.
        Outraged => "outraged",

        /// Interested in play; fun, recreational, unserious, lighthearted; joking, silly.
        Playful => "playful",

        /// Feeling a sense of one's own worth or accomplishment.
        Proud => "proud",

        /// Having an easy-going mood; not stressed; calm.
        Relaxed => "relaxed",

        /// Feeling uplifted because of the removal of stress or discomfort.
        Relieved => "relieved",

        /// Feeling regret or sadness for doing something wrong.
        Remorseful => "remorseful",

        /// Without rest; unable to be still or quiet; uneasy; continually moving.
        Restless => "restless",

        /// Feeling sorrow; sorrowful, mournful.
        Sad => "sad",

        /// Mocking and ironical.
        Sarcastic => "sarcastic",

        /// Pleased at the fulfillment of a need or desire.
        Satisfied => "satisfied",

        /// Without humor or expression of happiness; grave in manner or disposition; earnest; thoughtful; solemn.
        Serious => "serious",

        /// Surprised, startled, confused, or taken aback.
        Shocked => "shocked",

        /// Feeling easily frightened or scared; timid; reserved or coy.
        Shy => "shy",

        /// Feeling in poor health; ill.
        Sick => "sick",

        /// Feeling the need for sleep.
        Sleepy => "sleepy",

        /// Acting without planning; natural; impulsive.
        Spontaneous => "spontaneous",

        /// Suffering emotional pressure.
        Stressed => "stressed",

        /// Capable of producing great physical force; or, emotionally forceful, able, determined, unyielding.
        Strong => "strong",

        /// Experiencing a feeling caused by something unexpected.
        Surprised => "surprised",

        /// Showing appreciation or gratitude.
        Thankful => "thankful",

        /// Feeling the need to drink.
        Thirsty => "thirsty",

        /// In need of rest or sleep.
        Tired => "tired",

        /// [Feeling any emotion not defined here.]
        Undefined => "undefined",

        /// Lacking in force or ability, either physical or emotional.
        Weak => "weak",

        /// Thinking about unpleasant things that have happened or that might happen; feeling afraid and unhappy.
        Worried => "worried",
    }
);

generate_elem_id!(
    /// Free-form text description of the mood.
    Text,
    "text",
    MOOD
);

#[cfg(test)]
mod tests {
    use super::*;
    use crate::Element;
    use std::convert::TryFrom;

    #[cfg(target_pointer_width = "32")]
    #[test]
    fn test_size() {
        assert_size!(MoodEnum, 1);
        assert_size!(Text, 12);
    }

    #[cfg(target_pointer_width = "64")]
    #[test]
    fn test_size() {
        assert_size!(MoodEnum, 1);
        assert_size!(Text, 24);
    }

    #[test]
    fn test_simple() {
        let elem: Element = "<happy xmlns='http://jabber.org/protocol/mood'/>"
            .parse()
            .unwrap();
        let mood = MoodEnum::try_from(elem).unwrap();
        assert_eq!(mood, MoodEnum::Happy);
    }

    #[test]
    fn test_text() {
        let elem: Element = "<text xmlns='http://jabber.org/protocol/mood'>Yay!</text>"
            .parse()
            .unwrap();
        let elem2 = elem.clone();
        let text = Text::try_from(elem).unwrap();
        assert_eq!(text.0, String::from("Yay!"));

        let elem3 = text.into();
        assert_eq!(elem2, elem3);
    }
}