2017-11-24 05:20:36 +00:00
// 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/.
2024-07-10 14:38:00 +00:00
use xso ::{ AsXml , FromXml } ;
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
use crate ::ns ;
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Enum representing all of the possible values of the XEP-0107 moods.
#[ derive(FromXml, AsXml, PartialEq, Debug, Clone) ]
#[ xml(namespace = ns::MOOD, exhaustive) ]
pub enum MoodEnum {
/// Impressed with fear or apprehension; in fear; apprehensive.
#[ xml(name = " afraid " ) ]
Afraid ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Astonished; confounded with fear, surprise or wonder.
#[ xml(name = " amazed " ) ]
Amazed ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Inclined to love; having a propensity to love, or to sexual enjoyment; loving, fond, affectionate, passionate, lustful, sexual, etc.
#[ xml(name = " amorous " ) ]
Amorous ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// 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.
#[ xml(name = " angry " ) ]
Angry ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// To be disturbed or irritated, especially by continued or repeated acts.
#[ xml(name = " annoyed " ) ]
Annoyed ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Full of anxiety or disquietude; greatly concerned or solicitous, esp. respecting something future or unknown; being in painful suspense.
#[ xml(name = " anxious " ) ]
Anxious ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// To be stimulated in one's feelings, especially to be sexually stimulated.
#[ xml(name = " aroused " ) ]
Aroused ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Feeling shame or guilt.
#[ xml(name = " ashamed " ) ]
Ashamed ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Suffering from boredom; uninterested, without attention.
#[ xml(name = " bored " ) ]
Bored ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Strong in the face of fear; courageous.
#[ xml(name = " brave " ) ]
Brave ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Peaceful, quiet.
#[ xml(name = " calm " ) ]
Calm ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Taking care or caution; tentative.
#[ xml(name = " cautious " ) ]
Cautious ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Feeling the sensation of coldness, especially to the point of discomfort.
#[ xml(name = " cold " ) ]
Cold ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Feeling very sure of or positive about something, especially about one's own capabilities.
#[ xml(name = " confident " ) ]
Confident ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Chaotic, jumbled or muddled.
#[ xml(name = " confused " ) ]
Confused ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Feeling introspective or thoughtful.
#[ xml(name = " contemplative " ) ]
Contemplative ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Pleased at the satisfaction of a want or desire; satisfied.
#[ xml(name = " contented " ) ]
Contented ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Grouchy, irritable; easily upset.
#[ xml(name = " cranky " ) ]
Cranky ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Feeling out of control; feeling overly excited or enthusiastic.
#[ xml(name = " crazy " ) ]
Crazy ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Feeling original, expressive, or imaginative.
#[ xml(name = " creative " ) ]
Creative ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Inquisitive; tending to ask questions, investigate, or explore.
#[ xml(name = " curious " ) ]
Curious ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Feeling sad and dispirited.
#[ xml(name = " dejected " ) ]
Dejected ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Severely despondent and unhappy.
#[ xml(name = " depressed " ) ]
Depressed ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Defeated of expectation or hope; let down.
#[ xml(name = " disappointed " ) ]
Disappointed ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Filled with disgust; irritated and out of patience.
#[ xml(name = " disgusted " ) ]
Disgusted ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Feeling a sudden or complete loss of courage in the face of trouble or danger.
#[ xml(name = " dismayed " ) ]
Dismayed ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Having one's attention diverted; preoccupied.
#[ xml(name = " distracted " ) ]
Distracted ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Having a feeling of shameful discomfort.
#[ xml(name = " embarrassed " ) ]
Embarrassed ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Feeling pain by the excellence or good fortune of another.
#[ xml(name = " envious " ) ]
Envious ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Having great enthusiasm.
#[ xml(name = " excited " ) ]
Excited ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// In the mood for flirting.
#[ xml(name = " flirtatious " ) ]
Flirtatious ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Suffering from frustration; dissatisfied, agitated, or discontented because one is unable to perform an action or fulfill a desire.
#[ xml(name = " frustrated " ) ]
Frustrated ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Feeling appreciation or thanks.
#[ xml(name = " grateful " ) ]
Grateful ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Feeling very sad about something, especially something lost; mournful; sorrowful.
#[ xml(name = " grieving " ) ]
Grieving ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Unhappy and irritable.
#[ xml(name = " grumpy " ) ]
Grumpy ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Feeling responsible for wrongdoing; feeling blameworthy.
#[ xml(name = " guilty " ) ]
Guilty ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// 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.
#[ xml(name = " happy " ) ]
Happy ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Having a positive feeling, belief, or expectation that something wished for can or will happen.
#[ xml(name = " hopeful " ) ]
Hopeful ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Feeling the sensation of heat, especially to the point of discomfort.
#[ xml(name = " hot " ) ]
Hot ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Having or showing a modest or low estimate of one's own importance; feeling lowered in dignity or importance.
#[ xml(name = " humbled " ) ]
Humbled ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Feeling deprived of dignity or self-respect.
#[ xml(name = " humiliated " ) ]
Humiliated ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Having a physical need for food.
#[ xml(name = " hungry " ) ]
Hungry ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Wounded, injured, or pained, whether physically or emotionally.
#[ xml(name = " hurt " ) ]
Hurt ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Favourably affected by something or someone.
#[ xml(name = " impressed " ) ]
Impressed ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Feeling amazement at something or someone; or feeling a combination of fear and reverence.
#[ xml(name = " in_awe " ) ]
InAwe ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Feeling strong affection, care, liking, or attraction..
#[ xml(name = " in_love " ) ]
InLove ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Showing anger or indignation, especially at something unjust or wrong.
#[ xml(name = " indignant " ) ]
Indignant ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Showing great attention to something or someone; having or showing interest.
#[ xml(name = " interested " ) ]
Interested ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Under the influence of alcohol; drunk.
#[ xml(name = " intoxicated " ) ]
Intoxicated ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Feeling as if one cannot be defeated, overcome or denied.
#[ xml(name = " invincible " ) ]
Invincible ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Fearful of being replaced in position or affection.
#[ xml(name = " jealous " ) ]
Jealous ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Feeling isolated, empty, or abandoned.
#[ xml(name = " lonely " ) ]
Lonely ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Unable to find one's way, either physically or emotionally.
#[ xml(name = " lost " ) ]
Lost ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Feeling as if one will be favored by luck.
#[ xml(name = " lucky " ) ]
Lucky ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Causing or intending to cause intentional harm; bearing ill will towards another; cruel; malicious.
#[ xml(name = " mean " ) ]
Mean ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Given to sudden or frequent changes of mind or feeling; temperamental.
#[ xml(name = " moody " ) ]
Moody ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Easily agitated or alarmed; apprehensive or anxious.
#[ xml(name = " nervous " ) ]
Nervous ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Not having a strong mood or emotional state.
#[ xml(name = " neutral " ) ]
Neutral ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Feeling emotionally hurt, displeased, or insulted.
#[ xml(name = " offended " ) ]
Offended ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Feeling resentful anger caused by an extremely violent or vicious attack, or by an offensive, immoral, or indecent act.
#[ xml(name = " outraged " ) ]
Outraged ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Interested in play; fun, recreational, unserious, lighthearted; joking, silly.
#[ xml(name = " playful " ) ]
Playful ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Feeling a sense of one's own worth or accomplishment.
#[ xml(name = " proud " ) ]
Proud ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Having an easy-going mood; not stressed; calm.
#[ xml(name = " relaxed " ) ]
Relaxed ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Feeling uplifted because of the removal of stress or discomfort.
#[ xml(name = " relieved " ) ]
Relieved ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Feeling regret or sadness for doing something wrong.
#[ xml(name = " remorseful " ) ]
Remorseful ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Without rest; unable to be still or quiet; uneasy; continually moving.
#[ xml(name = " restless " ) ]
Restless ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Feeling sorrow; sorrowful, mournful.
#[ xml(name = " sad " ) ]
Sad ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Mocking and ironical.
#[ xml(name = " sarcastic " ) ]
Sarcastic ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Pleased at the fulfillment of a need or desire.
#[ xml(name = " satisfied " ) ]
Satisfied ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Without humor or expression of happiness; grave in manner or disposition; earnest; thoughtful; solemn.
#[ xml(name = " serious " ) ]
Serious ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Surprised, startled, confused, or taken aback.
#[ xml(name = " shocked " ) ]
Shocked ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Feeling easily frightened or scared; timid; reserved or coy.
#[ xml(name = " shy " ) ]
Shy ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Feeling in poor health; ill.
#[ xml(name = " sick " ) ]
Sick ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Feeling the need for sleep.
#[ xml(name = " sleepy " ) ]
Sleepy ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Acting without planning; natural; impulsive.
#[ xml(name = " spontaneous " ) ]
Spontaneous ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Suffering emotional pressure.
#[ xml(name = " stressed " ) ]
Stressed ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Capable of producing great physical force; or, emotionally forceful, able, determined, unyielding.
#[ xml(name = " strong " ) ]
Strong ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Experiencing a feeling caused by something unexpected.
#[ xml(name = " surprised " ) ]
Surprised ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Showing appreciation or gratitude.
#[ xml(name = " thankful " ) ]
Thankful ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// Feeling the need to drink.
#[ xml(name = " thirsty " ) ]
Thirsty ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// In need of rest or sleep.
#[ xml(name = " tired " ) ]
Tired ,
2017-11-24 05:20:36 +00:00
2024-07-10 14:38:00 +00:00
/// [Feeling any emotion not defined here.]
#[ xml(name = " undefined " ) ]
Undefined ,
/// Lacking in force or ability, either physical or emotional.
#[ xml(name = " weak " ) ]
Weak ,
/// Thinking about unpleasant things that have happened or that might happen; feeling afraid and unhappy.
#[ xml(name = " worried " ) ]
Worried ,
}
2017-11-24 05:20:36 +00:00
2018-05-14 15:32:15 +00:00
generate_elem_id! (
/// Free-form text description of the mood.
2018-12-18 14:32:05 +00:00
Text ,
" text " ,
MOOD
2018-05-14 15:32:15 +00:00
) ;
2017-11-24 05:20:36 +00:00
#[ cfg(test) ]
mod tests {
use super ::* ;
2024-07-24 18:28:22 +00:00
use minidom ::Element ;
2017-11-24 05:20:36 +00:00
2018-10-28 12:10:48 +00:00
#[ cfg(target_pointer_width = " 32 " ) ]
#[ test ]
fn test_size ( ) {
assert_size! ( MoodEnum , 1 ) ;
assert_size! ( Text , 12 ) ;
}
#[ cfg(target_pointer_width = " 64 " ) ]
2018-10-26 12:26:16 +00:00
#[ test ]
fn test_size ( ) {
assert_size! ( MoodEnum , 1 ) ;
assert_size! ( Text , 24 ) ;
}
2017-11-24 05:20:36 +00:00
#[ test ]
fn test_simple ( ) {
2018-12-18 14:32:05 +00:00
let elem : Element = " <happy xmlns='http://jabber.org/protocol/mood'/> "
. parse ( )
. unwrap ( ) ;
2017-11-24 05:20:36 +00:00
let mood = MoodEnum ::try_from ( elem ) . unwrap ( ) ;
assert_eq! ( mood , MoodEnum ::Happy ) ;
}
2018-05-14 15:32:15 +00:00
#[ test ]
fn test_text ( ) {
2018-12-18 14:32:05 +00:00
let elem : Element = " <text xmlns='http://jabber.org/protocol/mood'>Yay!</text> "
. parse ( )
. unwrap ( ) ;
2019-09-05 13:34:21 +00:00
let elem2 = elem . clone ( ) ;
2018-05-14 15:32:15 +00:00
let text = Text ::try_from ( elem ) . unwrap ( ) ;
assert_eq! ( text . 0 , String ::from ( " Yay! " ) ) ;
2019-09-05 13:34:21 +00:00
let elem3 = text . into ( ) ;
assert_eq! ( elem2 , elem3 ) ;
2018-05-14 15:32:15 +00:00
}
2017-11-24 05:20:36 +00:00
}