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