parsers: port enums over to derive macros
This commit is contained in:
parent
c028c3b91a
commit
6afd0ef52f
7 changed files with 563 additions and 428 deletions
|
|
@ -1,5 +1,10 @@
|
||||||
Version NEXT:
|
Version NEXT:
|
||||||
XXXX-YY-ZZ RELEASER <admin@example.com>
|
XXXX-YY-ZZ RELEASER <admin@example.com>
|
||||||
|
* Breaking
|
||||||
|
- The `alternate_address` field of
|
||||||
|
`xmpp_parsers::stanza_error::StanzaError` has been moved into the
|
||||||
|
corresponding enum variants of the
|
||||||
|
`xmpp_parsers::stanza_error::DefinedCondition` where it may occur.
|
||||||
* New parsers/serialisers:
|
* New parsers/serialisers:
|
||||||
- Stream Features (RFC 6120) (!400)
|
- Stream Features (RFC 6120) (!400)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,28 +4,36 @@
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// 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/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
use xso::{AsXml, FromXml};
|
||||||
|
|
||||||
use crate::message::MessagePayload;
|
use crate::message::MessagePayload;
|
||||||
|
use crate::ns;
|
||||||
|
|
||||||
generate_element_enum!(
|
/// Enum representing chatstate elements part of the
|
||||||
/// Enum representing chatstate elements part of the
|
/// `http://jabber.org/protocol/chatstates` namespace.
|
||||||
/// `http://jabber.org/protocol/chatstates` namespace.
|
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||||
ChatState, "chatstate", CHATSTATES, {
|
#[xml(namespace = ns::CHATSTATES, exhaustive)]
|
||||||
/// `<active xmlns='http://jabber.org/protocol/chatstates'/>`
|
pub enum ChatState {
|
||||||
Active => "active",
|
/// `<active xmlns='http://jabber.org/protocol/chatstates'/>`
|
||||||
|
#[xml(name = "active")]
|
||||||
|
Active,
|
||||||
|
|
||||||
/// `<composing xmlns='http://jabber.org/protocol/chatstates'/>`
|
/// `<composing xmlns='http://jabber.org/protocol/chatstates'/>`
|
||||||
Composing => "composing",
|
#[xml(name = "composing")]
|
||||||
|
Composing,
|
||||||
|
|
||||||
/// `<gone xmlns='http://jabber.org/protocol/chatstates'/>`
|
/// `<gone xmlns='http://jabber.org/protocol/chatstates'/>`
|
||||||
Gone => "gone",
|
#[xml(name = "gone")]
|
||||||
|
Gone,
|
||||||
|
|
||||||
/// `<inactive xmlns='http://jabber.org/protocol/chatstates'/>`
|
/// `<inactive xmlns='http://jabber.org/protocol/chatstates'/>`
|
||||||
Inactive => "inactive",
|
#[xml(name = "inactive")]
|
||||||
|
Inactive,
|
||||||
|
|
||||||
/// `<paused xmlns='http://jabber.org/protocol/chatstates'/>`
|
/// `<paused xmlns='http://jabber.org/protocol/chatstates'/>`
|
||||||
Paused => "paused",
|
#[xml(name = "paused")]
|
||||||
}
|
Paused,
|
||||||
);
|
}
|
||||||
|
|
||||||
impl MessagePayload for ChatState {}
|
impl MessagePayload for ChatState {}
|
||||||
|
|
||||||
|
|
@ -59,7 +67,7 @@ mod tests {
|
||||||
FromElementError::Invalid(Error::Other(string)) => string,
|
FromElementError::Invalid(Error::Other(string)) => string,
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
};
|
};
|
||||||
assert_eq!(message, "This is not a chatstate element.");
|
assert_eq!(message, "This is not a ChatState element.");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "disable-validation"))]
|
#[cfg(not(feature = "disable-validation"))]
|
||||||
|
|
@ -73,7 +81,7 @@ mod tests {
|
||||||
FromElementError::Invalid(Error::Other(string)) => string,
|
FromElementError::Invalid(Error::Other(string)) => string,
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
};
|
};
|
||||||
assert_eq!(message, "Unknown child in chatstate element.");
|
assert_eq!(message, "Unknown child in ChatState::Gone element.");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "disable-validation"))]
|
#[cfg(not(feature = "disable-validation"))]
|
||||||
|
|
@ -87,7 +95,7 @@ mod tests {
|
||||||
FromElementError::Invalid(Error::Other(string)) => string,
|
FromElementError::Invalid(Error::Other(string)) => string,
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
};
|
};
|
||||||
assert_eq!(message, "Unknown attribute in chatstate element.");
|
assert_eq!(message, "Unknown attribute in ChatState::Inactive element.");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -232,15 +232,15 @@ mod tests {
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_size() {
|
fn test_size() {
|
||||||
assert_size!(IqType, 104);
|
assert_size!(IqType, 108);
|
||||||
assert_size!(Iq, 148);
|
assert_size!(Iq, 152);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "64")]
|
#[cfg(target_pointer_width = "64")]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_size() {
|
fn test_size() {
|
||||||
assert_size!(IqType, 208);
|
assert_size!(IqType, 216);
|
||||||
assert_size!(Iq, 296);
|
assert_size!(Iq, 304);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -4,262 +4,350 @@
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// 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/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
generate_element_enum!(
|
use xso::{AsXml, FromXml};
|
||||||
/// 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.
|
use crate::ns;
|
||||||
Amazed => "amazed",
|
|
||||||
|
|
||||||
/// Inclined to love; having a propensity to love, or to sexual enjoyment; loving, fond, affectionate, passionate, lustful, sexual, etc.
|
/// Enum representing all of the possible values of the XEP-0107 moods.
|
||||||
Amorous => "amorous",
|
#[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,
|
||||||
|
|
||||||
/// 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.
|
/// Astonished; confounded with fear, surprise or wonder.
|
||||||
Angry => "angry",
|
#[xml(name = "amazed")]
|
||||||
|
Amazed,
|
||||||
|
|
||||||
/// To be disturbed or irritated, especially by continued or repeated acts.
|
/// Inclined to love; having a propensity to love, or to sexual enjoyment; loving, fond, affectionate, passionate, lustful, sexual, etc.
|
||||||
Annoyed => "annoyed",
|
#[xml(name = "amorous")]
|
||||||
|
Amorous,
|
||||||
|
|
||||||
/// Full of anxiety or disquietude; greatly concerned or solicitous, esp. respecting something future or unknown; being in painful suspense.
|
/// 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.
|
||||||
Anxious => "anxious",
|
#[xml(name = "angry")]
|
||||||
|
Angry,
|
||||||
|
|
||||||
/// To be stimulated in one's feelings, especially to be sexually stimulated.
|
/// To be disturbed or irritated, especially by continued or repeated acts.
|
||||||
Aroused => "aroused",
|
#[xml(name = "annoyed")]
|
||||||
|
Annoyed,
|
||||||
|
|
||||||
/// Feeling shame or guilt.
|
/// Full of anxiety or disquietude; greatly concerned or solicitous, esp. respecting something future or unknown; being in painful suspense.
|
||||||
Ashamed => "ashamed",
|
#[xml(name = "anxious")]
|
||||||
|
Anxious,
|
||||||
|
|
||||||
/// Suffering from boredom; uninterested, without attention.
|
/// To be stimulated in one's feelings, especially to be sexually stimulated.
|
||||||
Bored => "bored",
|
#[xml(name = "aroused")]
|
||||||
|
Aroused,
|
||||||
|
|
||||||
/// Strong in the face of fear; courageous.
|
/// Feeling shame or guilt.
|
||||||
Brave => "brave",
|
#[xml(name = "ashamed")]
|
||||||
|
Ashamed,
|
||||||
|
|
||||||
/// Peaceful, quiet.
|
/// Suffering from boredom; uninterested, without attention.
|
||||||
Calm => "calm",
|
#[xml(name = "bored")]
|
||||||
|
Bored,
|
||||||
|
|
||||||
/// Taking care or caution; tentative.
|
/// Strong in the face of fear; courageous.
|
||||||
Cautious => "cautious",
|
#[xml(name = "brave")]
|
||||||
|
Brave,
|
||||||
|
|
||||||
/// Feeling the sensation of coldness, especially to the point of discomfort.
|
/// Peaceful, quiet.
|
||||||
Cold => "cold",
|
#[xml(name = "calm")]
|
||||||
|
Calm,
|
||||||
|
|
||||||
/// Feeling very sure of or positive about something, especially about one's own capabilities.
|
/// Taking care or caution; tentative.
|
||||||
Confident => "confident",
|
#[xml(name = "cautious")]
|
||||||
|
Cautious,
|
||||||
|
|
||||||
/// Chaotic, jumbled or muddled.
|
/// Feeling the sensation of coldness, especially to the point of discomfort.
|
||||||
Confused => "confused",
|
#[xml(name = "cold")]
|
||||||
|
Cold,
|
||||||
|
|
||||||
/// Feeling introspective or thoughtful.
|
/// Feeling very sure of or positive about something, especially about one's own capabilities.
|
||||||
Contemplative => "contemplative",
|
#[xml(name = "confident")]
|
||||||
|
Confident,
|
||||||
|
|
||||||
/// Pleased at the satisfaction of a want or desire; satisfied.
|
/// Chaotic, jumbled or muddled.
|
||||||
Contented => "contented",
|
#[xml(name = "confused")]
|
||||||
|
Confused,
|
||||||
|
|
||||||
/// Grouchy, irritable; easily upset.
|
/// Feeling introspective or thoughtful.
|
||||||
Cranky => "cranky",
|
#[xml(name = "contemplative")]
|
||||||
|
Contemplative,
|
||||||
|
|
||||||
/// Feeling out of control; feeling overly excited or enthusiastic.
|
/// Pleased at the satisfaction of a want or desire; satisfied.
|
||||||
Crazy => "crazy",
|
#[xml(name = "contented")]
|
||||||
|
Contented,
|
||||||
|
|
||||||
/// Feeling original, expressive, or imaginative.
|
/// Grouchy, irritable; easily upset.
|
||||||
Creative => "creative",
|
#[xml(name = "cranky")]
|
||||||
|
Cranky,
|
||||||
|
|
||||||
/// Inquisitive; tending to ask questions, investigate, or explore.
|
/// Feeling out of control; feeling overly excited or enthusiastic.
|
||||||
Curious => "curious",
|
#[xml(name = "crazy")]
|
||||||
|
Crazy,
|
||||||
|
|
||||||
/// Feeling sad and dispirited.
|
/// Feeling original, expressive, or imaginative.
|
||||||
Dejected => "dejected",
|
#[xml(name = "creative")]
|
||||||
|
Creative,
|
||||||
|
|
||||||
/// Severely despondent and unhappy.
|
/// Inquisitive; tending to ask questions, investigate, or explore.
|
||||||
Depressed => "depressed",
|
#[xml(name = "curious")]
|
||||||
|
Curious,
|
||||||
|
|
||||||
/// Defeated of expectation or hope; let down.
|
/// Feeling sad and dispirited.
|
||||||
Disappointed => "disappointed",
|
#[xml(name = "dejected")]
|
||||||
|
Dejected,
|
||||||
|
|
||||||
/// Filled with disgust; irritated and out of patience.
|
/// Severely despondent and unhappy.
|
||||||
Disgusted => "disgusted",
|
#[xml(name = "depressed")]
|
||||||
|
Depressed,
|
||||||
|
|
||||||
/// Feeling a sudden or complete loss of courage in the face of trouble or danger.
|
/// Defeated of expectation or hope; let down.
|
||||||
Dismayed => "dismayed",
|
#[xml(name = "disappointed")]
|
||||||
|
Disappointed,
|
||||||
|
|
||||||
/// Having one's attention diverted; preoccupied.
|
/// Filled with disgust; irritated and out of patience.
|
||||||
Distracted => "distracted",
|
#[xml(name = "disgusted")]
|
||||||
|
Disgusted,
|
||||||
|
|
||||||
/// Having a feeling of shameful discomfort.
|
/// Feeling a sudden or complete loss of courage in the face of trouble or danger.
|
||||||
Embarrassed => "embarrassed",
|
#[xml(name = "dismayed")]
|
||||||
|
Dismayed,
|
||||||
|
|
||||||
/// Feeling pain by the excellence or good fortune of another.
|
/// Having one's attention diverted; preoccupied.
|
||||||
Envious => "envious",
|
#[xml(name = "distracted")]
|
||||||
|
Distracted,
|
||||||
|
|
||||||
/// Having great enthusiasm.
|
/// Having a feeling of shameful discomfort.
|
||||||
Excited => "excited",
|
#[xml(name = "embarrassed")]
|
||||||
|
Embarrassed,
|
||||||
|
|
||||||
/// In the mood for flirting.
|
/// Feeling pain by the excellence or good fortune of another.
|
||||||
Flirtatious => "flirtatious",
|
#[xml(name = "envious")]
|
||||||
|
Envious,
|
||||||
|
|
||||||
/// Suffering from frustration; dissatisfied, agitated, or discontented because one is unable to perform an action or fulfill a desire.
|
/// Having great enthusiasm.
|
||||||
Frustrated => "frustrated",
|
#[xml(name = "excited")]
|
||||||
|
Excited,
|
||||||
|
|
||||||
/// Feeling appreciation or thanks.
|
/// In the mood for flirting.
|
||||||
Grateful => "grateful",
|
#[xml(name = "flirtatious")]
|
||||||
|
Flirtatious,
|
||||||
|
|
||||||
/// Feeling very sad about something, especially something lost; mournful; sorrowful.
|
/// Suffering from frustration; dissatisfied, agitated, or discontented because one is unable to perform an action or fulfill a desire.
|
||||||
Grieving => "grieving",
|
#[xml(name = "frustrated")]
|
||||||
|
Frustrated,
|
||||||
|
|
||||||
/// Unhappy and irritable.
|
/// Feeling appreciation or thanks.
|
||||||
Grumpy => "grumpy",
|
#[xml(name = "grateful")]
|
||||||
|
Grateful,
|
||||||
|
|
||||||
/// Feeling responsible for wrongdoing; feeling blameworthy.
|
/// Feeling very sad about something, especially something lost; mournful; sorrowful.
|
||||||
Guilty => "guilty",
|
#[xml(name = "grieving")]
|
||||||
|
Grieving,
|
||||||
|
|
||||||
/// 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.
|
/// Unhappy and irritable.
|
||||||
Happy => "happy",
|
#[xml(name = "grumpy")]
|
||||||
|
Grumpy,
|
||||||
|
|
||||||
/// Having a positive feeling, belief, or expectation that something wished for can or will happen.
|
/// Feeling responsible for wrongdoing; feeling blameworthy.
|
||||||
Hopeful => "hopeful",
|
#[xml(name = "guilty")]
|
||||||
|
Guilty,
|
||||||
|
|
||||||
/// Feeling the sensation of heat, especially to the point of discomfort.
|
/// 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.
|
||||||
Hot => "hot",
|
#[xml(name = "happy")]
|
||||||
|
Happy,
|
||||||
|
|
||||||
/// Having or showing a modest or low estimate of one's own importance; feeling lowered in dignity or importance.
|
/// Having a positive feeling, belief, or expectation that something wished for can or will happen.
|
||||||
Humbled => "humbled",
|
#[xml(name = "hopeful")]
|
||||||
|
Hopeful,
|
||||||
|
|
||||||
/// Feeling deprived of dignity or self-respect.
|
/// Feeling the sensation of heat, especially to the point of discomfort.
|
||||||
Humiliated => "humiliated",
|
#[xml(name = "hot")]
|
||||||
|
Hot,
|
||||||
|
|
||||||
/// Having a physical need for food.
|
/// Having or showing a modest or low estimate of one's own importance; feeling lowered in dignity or importance.
|
||||||
Hungry => "hungry",
|
#[xml(name = "humbled")]
|
||||||
|
Humbled,
|
||||||
|
|
||||||
/// Wounded, injured, or pained, whether physically or emotionally.
|
/// Feeling deprived of dignity or self-respect.
|
||||||
Hurt => "hurt",
|
#[xml(name = "humiliated")]
|
||||||
|
Humiliated,
|
||||||
|
|
||||||
/// Favourably affected by something or someone.
|
/// Having a physical need for food.
|
||||||
Impressed => "impressed",
|
#[xml(name = "hungry")]
|
||||||
|
Hungry,
|
||||||
|
|
||||||
/// Feeling amazement at something or someone; or feeling a combination of fear and reverence.
|
/// Wounded, injured, or pained, whether physically or emotionally.
|
||||||
InAwe => "in_awe",
|
#[xml(name = "hurt")]
|
||||||
|
Hurt,
|
||||||
|
|
||||||
/// Feeling strong affection, care, liking, or attraction..
|
/// Favourably affected by something or someone.
|
||||||
InLove => "in_love",
|
#[xml(name = "impressed")]
|
||||||
|
Impressed,
|
||||||
|
|
||||||
/// Showing anger or indignation, especially at something unjust or wrong.
|
/// Feeling amazement at something or someone; or feeling a combination of fear and reverence.
|
||||||
Indignant => "indignant",
|
#[xml(name = "in_awe")]
|
||||||
|
InAwe,
|
||||||
|
|
||||||
/// Showing great attention to something or someone; having or showing interest.
|
/// Feeling strong affection, care, liking, or attraction..
|
||||||
Interested => "interested",
|
#[xml(name = "in_love")]
|
||||||
|
InLove,
|
||||||
|
|
||||||
/// Under the influence of alcohol; drunk.
|
/// Showing anger or indignation, especially at something unjust or wrong.
|
||||||
Intoxicated => "intoxicated",
|
#[xml(name = "indignant")]
|
||||||
|
Indignant,
|
||||||
|
|
||||||
/// Feeling as if one cannot be defeated, overcome or denied.
|
/// Showing great attention to something or someone; having or showing interest.
|
||||||
Invincible => "invincible",
|
#[xml(name = "interested")]
|
||||||
|
Interested,
|
||||||
|
|
||||||
/// Fearful of being replaced in position or affection.
|
/// Under the influence of alcohol; drunk.
|
||||||
Jealous => "jealous",
|
#[xml(name = "intoxicated")]
|
||||||
|
Intoxicated,
|
||||||
|
|
||||||
/// Feeling isolated, empty, or abandoned.
|
/// Feeling as if one cannot be defeated, overcome or denied.
|
||||||
Lonely => "lonely",
|
#[xml(name = "invincible")]
|
||||||
|
Invincible,
|
||||||
|
|
||||||
/// Unable to find one's way, either physically or emotionally.
|
/// Fearful of being replaced in position or affection.
|
||||||
Lost => "lost",
|
#[xml(name = "jealous")]
|
||||||
|
Jealous,
|
||||||
|
|
||||||
/// Feeling as if one will be favored by luck.
|
/// Feeling isolated, empty, or abandoned.
|
||||||
Lucky => "lucky",
|
#[xml(name = "lonely")]
|
||||||
|
Lonely,
|
||||||
|
|
||||||
/// Causing or intending to cause intentional harm; bearing ill will towards another; cruel; malicious.
|
/// Unable to find one's way, either physically or emotionally.
|
||||||
Mean => "mean",
|
#[xml(name = "lost")]
|
||||||
|
Lost,
|
||||||
|
|
||||||
/// Given to sudden or frequent changes of mind or feeling; temperamental.
|
/// Feeling as if one will be favored by luck.
|
||||||
Moody => "moody",
|
#[xml(name = "lucky")]
|
||||||
|
Lucky,
|
||||||
|
|
||||||
/// Easily agitated or alarmed; apprehensive or anxious.
|
/// Causing or intending to cause intentional harm; bearing ill will towards another; cruel; malicious.
|
||||||
Nervous => "nervous",
|
#[xml(name = "mean")]
|
||||||
|
Mean,
|
||||||
|
|
||||||
/// Not having a strong mood or emotional state.
|
/// Given to sudden or frequent changes of mind or feeling; temperamental.
|
||||||
Neutral => "neutral",
|
#[xml(name = "moody")]
|
||||||
|
Moody,
|
||||||
|
|
||||||
/// Feeling emotionally hurt, displeased, or insulted.
|
/// Easily agitated or alarmed; apprehensive or anxious.
|
||||||
Offended => "offended",
|
#[xml(name = "nervous")]
|
||||||
|
Nervous,
|
||||||
|
|
||||||
/// Feeling resentful anger caused by an extremely violent or vicious attack, or by an offensive, immoral, or indecent act.
|
/// Not having a strong mood or emotional state.
|
||||||
Outraged => "outraged",
|
#[xml(name = "neutral")]
|
||||||
|
Neutral,
|
||||||
|
|
||||||
/// Interested in play; fun, recreational, unserious, lighthearted; joking, silly.
|
/// Feeling emotionally hurt, displeased, or insulted.
|
||||||
Playful => "playful",
|
#[xml(name = "offended")]
|
||||||
|
Offended,
|
||||||
|
|
||||||
/// Feeling a sense of one's own worth or accomplishment.
|
/// Feeling resentful anger caused by an extremely violent or vicious attack, or by an offensive, immoral, or indecent act.
|
||||||
Proud => "proud",
|
#[xml(name = "outraged")]
|
||||||
|
Outraged,
|
||||||
|
|
||||||
/// Having an easy-going mood; not stressed; calm.
|
/// Interested in play; fun, recreational, unserious, lighthearted; joking, silly.
|
||||||
Relaxed => "relaxed",
|
#[xml(name = "playful")]
|
||||||
|
Playful,
|
||||||
|
|
||||||
/// Feeling uplifted because of the removal of stress or discomfort.
|
/// Feeling a sense of one's own worth or accomplishment.
|
||||||
Relieved => "relieved",
|
#[xml(name = "proud")]
|
||||||
|
Proud,
|
||||||
|
|
||||||
/// Feeling regret or sadness for doing something wrong.
|
/// Having an easy-going mood; not stressed; calm.
|
||||||
Remorseful => "remorseful",
|
#[xml(name = "relaxed")]
|
||||||
|
Relaxed,
|
||||||
|
|
||||||
/// Without rest; unable to be still or quiet; uneasy; continually moving.
|
/// Feeling uplifted because of the removal of stress or discomfort.
|
||||||
Restless => "restless",
|
#[xml(name = "relieved")]
|
||||||
|
Relieved,
|
||||||
|
|
||||||
/// Feeling sorrow; sorrowful, mournful.
|
/// Feeling regret or sadness for doing something wrong.
|
||||||
Sad => "sad",
|
#[xml(name = "remorseful")]
|
||||||
|
Remorseful,
|
||||||
|
|
||||||
/// Mocking and ironical.
|
/// Without rest; unable to be still or quiet; uneasy; continually moving.
|
||||||
Sarcastic => "sarcastic",
|
#[xml(name = "restless")]
|
||||||
|
Restless,
|
||||||
|
|
||||||
/// Pleased at the fulfillment of a need or desire.
|
/// Feeling sorrow; sorrowful, mournful.
|
||||||
Satisfied => "satisfied",
|
#[xml(name = "sad")]
|
||||||
|
Sad,
|
||||||
|
|
||||||
/// Without humor or expression of happiness; grave in manner or disposition; earnest; thoughtful; solemn.
|
/// Mocking and ironical.
|
||||||
Serious => "serious",
|
#[xml(name = "sarcastic")]
|
||||||
|
Sarcastic,
|
||||||
|
|
||||||
/// Surprised, startled, confused, or taken aback.
|
/// Pleased at the fulfillment of a need or desire.
|
||||||
Shocked => "shocked",
|
#[xml(name = "satisfied")]
|
||||||
|
Satisfied,
|
||||||
|
|
||||||
/// Feeling easily frightened or scared; timid; reserved or coy.
|
/// Without humor or expression of happiness; grave in manner or disposition; earnest; thoughtful; solemn.
|
||||||
Shy => "shy",
|
#[xml(name = "serious")]
|
||||||
|
Serious,
|
||||||
|
|
||||||
/// Feeling in poor health; ill.
|
/// Surprised, startled, confused, or taken aback.
|
||||||
Sick => "sick",
|
#[xml(name = "shocked")]
|
||||||
|
Shocked,
|
||||||
|
|
||||||
/// Feeling the need for sleep.
|
/// Feeling easily frightened or scared; timid; reserved or coy.
|
||||||
Sleepy => "sleepy",
|
#[xml(name = "shy")]
|
||||||
|
Shy,
|
||||||
|
|
||||||
/// Acting without planning; natural; impulsive.
|
/// Feeling in poor health; ill.
|
||||||
Spontaneous => "spontaneous",
|
#[xml(name = "sick")]
|
||||||
|
Sick,
|
||||||
|
|
||||||
/// Suffering emotional pressure.
|
/// Feeling the need for sleep.
|
||||||
Stressed => "stressed",
|
#[xml(name = "sleepy")]
|
||||||
|
Sleepy,
|
||||||
|
|
||||||
/// Capable of producing great physical force; or, emotionally forceful, able, determined, unyielding.
|
/// Acting without planning; natural; impulsive.
|
||||||
Strong => "strong",
|
#[xml(name = "spontaneous")]
|
||||||
|
Spontaneous,
|
||||||
|
|
||||||
/// Experiencing a feeling caused by something unexpected.
|
/// Suffering emotional pressure.
|
||||||
Surprised => "surprised",
|
#[xml(name = "stressed")]
|
||||||
|
Stressed,
|
||||||
|
|
||||||
/// Showing appreciation or gratitude.
|
/// Capable of producing great physical force; or, emotionally forceful, able, determined, unyielding.
|
||||||
Thankful => "thankful",
|
#[xml(name = "strong")]
|
||||||
|
Strong,
|
||||||
|
|
||||||
/// Feeling the need to drink.
|
/// Experiencing a feeling caused by something unexpected.
|
||||||
Thirsty => "thirsty",
|
#[xml(name = "surprised")]
|
||||||
|
Surprised,
|
||||||
|
|
||||||
/// In need of rest or sleep.
|
/// Showing appreciation or gratitude.
|
||||||
Tired => "tired",
|
#[xml(name = "thankful")]
|
||||||
|
Thankful,
|
||||||
|
|
||||||
/// [Feeling any emotion not defined here.]
|
/// Feeling the need to drink.
|
||||||
Undefined => "undefined",
|
#[xml(name = "thirsty")]
|
||||||
|
Thirsty,
|
||||||
|
|
||||||
/// Lacking in force or ability, either physical or emotional.
|
/// In need of rest or sleep.
|
||||||
Weak => "weak",
|
#[xml(name = "tired")]
|
||||||
|
Tired,
|
||||||
|
|
||||||
/// Thinking about unpleasant things that have happened or that might happen; feeling afraid and unhappy.
|
/// [Feeling any emotion not defined here.]
|
||||||
Worried => "worried",
|
#[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,
|
||||||
|
}
|
||||||
|
|
||||||
generate_elem_id!(
|
generate_elem_id!(
|
||||||
/// Free-form text description of the mood.
|
/// Free-form text description of the mood.
|
||||||
|
|
|
||||||
|
|
@ -97,47 +97,58 @@ pub struct Success {
|
||||||
pub data: Vec<u8>,
|
pub data: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
generate_element_enum!(
|
/// List of possible failure conditions for SASL.
|
||||||
/// List of possible failure conditions for SASL.
|
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||||
DefinedCondition, "defined-condition", SASL, {
|
#[xml(namespace = ns::SASL, exhaustive)]
|
||||||
/// The client aborted the authentication with
|
pub enum DefinedCondition {
|
||||||
/// [abort](struct.Abort.html).
|
/// The client aborted the authentication with
|
||||||
Aborted => "aborted",
|
/// [abort](struct.Abort.html).
|
||||||
|
#[xml(name = "aborted")]
|
||||||
|
Aborted,
|
||||||
|
|
||||||
/// The account the client is trying to authenticate against has been
|
/// The account the client is trying to authenticate against has been
|
||||||
/// disabled.
|
/// disabled.
|
||||||
AccountDisabled => "account-disabled",
|
#[xml(name = "account-disabled")]
|
||||||
|
AccountDisabled,
|
||||||
|
|
||||||
/// The credentials for this account have expired.
|
/// The credentials for this account have expired.
|
||||||
CredentialsExpired => "credentials-expired",
|
#[xml(name = "credentials-expired")]
|
||||||
|
CredentialsExpired,
|
||||||
|
|
||||||
/// You must enable StartTLS or use direct TLS before using this
|
/// You must enable StartTLS or use direct TLS before using this
|
||||||
/// authentication mechanism.
|
/// authentication mechanism.
|
||||||
EncryptionRequired => "encryption-required",
|
#[xml(name = "encryption-required")]
|
||||||
|
EncryptionRequired,
|
||||||
|
|
||||||
/// The base64 data sent by the client is invalid.
|
/// The base64 data sent by the client is invalid.
|
||||||
IncorrectEncoding => "incorrect-encoding",
|
#[xml(name = "incorrect-encoding")]
|
||||||
|
IncorrectEncoding,
|
||||||
|
|
||||||
/// The authzid provided by the client is invalid.
|
/// The authzid provided by the client is invalid.
|
||||||
InvalidAuthzid => "invalid-authzid",
|
#[xml(name = "invalid-authzid")]
|
||||||
|
InvalidAuthzid,
|
||||||
|
|
||||||
/// The client tried to use an invalid mechanism, or none.
|
/// The client tried to use an invalid mechanism, or none.
|
||||||
InvalidMechanism => "invalid-mechanism",
|
#[xml(name = "invalid-mechanism")]
|
||||||
|
InvalidMechanism,
|
||||||
|
|
||||||
/// The client sent a bad request.
|
/// The client sent a bad request.
|
||||||
MalformedRequest => "malformed-request",
|
#[xml(name = "malformed-request")]
|
||||||
|
MalformedRequest,
|
||||||
|
|
||||||
/// The mechanism selected is weaker than what the server allows.
|
/// The mechanism selected is weaker than what the server allows.
|
||||||
MechanismTooWeak => "mechanism-too-weak",
|
#[xml(name = "mechanism-too-weak")]
|
||||||
|
MechanismTooWeak,
|
||||||
|
|
||||||
/// The credentials provided are invalid.
|
/// The credentials provided are invalid.
|
||||||
NotAuthorized => "not-authorized",
|
#[xml(name = "not-authorized")]
|
||||||
|
NotAuthorized,
|
||||||
|
|
||||||
/// The server encountered an issue which may be fixed later, the
|
/// The server encountered an issue which may be fixed later, the
|
||||||
/// client should retry at some point.
|
/// client should retry at some point.
|
||||||
TemporaryAuthFailure => "temporary-auth-failure",
|
#[xml(name = "temporary-auth-failure")]
|
||||||
}
|
TemporaryAuthFailure,
|
||||||
);
|
}
|
||||||
|
|
||||||
type Lang = String;
|
type Lang = String;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@ mod tests {
|
||||||
assert_size!(Enable, 12);
|
assert_size!(Enable, 12);
|
||||||
assert_size!(StreamId, 12);
|
assert_size!(StreamId, 12);
|
||||||
assert_size!(Enabled, 36);
|
assert_size!(Enabled, 36);
|
||||||
assert_size!(Failed, 12);
|
assert_size!(Failed, 24);
|
||||||
assert_size!(R, 0);
|
assert_size!(R, 0);
|
||||||
assert_size!(Resume, 16);
|
assert_size!(Resume, 16);
|
||||||
assert_size!(Resumed, 16);
|
assert_size!(Resumed, 16);
|
||||||
|
|
@ -174,7 +174,7 @@ mod tests {
|
||||||
assert_size!(Enable, 12);
|
assert_size!(Enable, 12);
|
||||||
assert_size!(StreamId, 24);
|
assert_size!(StreamId, 24);
|
||||||
assert_size!(Enabled, 64);
|
assert_size!(Enabled, 64);
|
||||||
assert_size!(Failed, 12);
|
assert_size!(Failed, 40);
|
||||||
assert_size!(R, 0);
|
assert_size!(R, 0);
|
||||||
assert_size!(Resume, 32);
|
assert_size!(Resume, 32);
|
||||||
assert_size!(Resumed, 32);
|
assert_size!(Resumed, 32);
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,13 @@
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// 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/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
use xso::{text::EmptyAsNone, AsXml, FromXml};
|
||||||
|
|
||||||
use crate::message::MessagePayload;
|
use crate::message::MessagePayload;
|
||||||
use crate::ns;
|
use crate::ns;
|
||||||
use crate::presence::PresencePayload;
|
use crate::presence::PresencePayload;
|
||||||
use jid::Jid;
|
use jid::Jid;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use minidom::Node;
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use xso::error::{Error, FromElementError};
|
use xso::error::{Error, FromElementError};
|
||||||
|
|
@ -34,163 +35,195 @@ generate_attribute!(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
generate_element_enum!(
|
/// List of valid error conditions.
|
||||||
/// List of valid error conditions.
|
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||||
DefinedCondition, "condition", XMPP_STANZAS, {
|
#[xml(namespace = ns::XMPP_STANZAS, exhaustive)]
|
||||||
/// The sender has sent a stanza containing XML that does not conform
|
pub enum DefinedCondition {
|
||||||
/// to the appropriate schema or that cannot be processed (e.g., an IQ
|
/// The sender has sent a stanza containing XML that does not conform
|
||||||
/// stanza that includes an unrecognized value of the 'type' attribute,
|
/// to the appropriate schema or that cannot be processed (e.g., an IQ
|
||||||
/// or an element that is qualified by a recognized namespace but that
|
/// stanza that includes an unrecognized value of the 'type' attribute,
|
||||||
/// violates the defined syntax for the element); the associated error
|
/// or an element that is qualified by a recognized namespace but that
|
||||||
/// type SHOULD be "modify".
|
/// violates the defined syntax for the element); the associated error
|
||||||
BadRequest => "bad-request",
|
/// type SHOULD be "modify".
|
||||||
|
#[xml(name = "bad-request")]
|
||||||
|
BadRequest,
|
||||||
|
|
||||||
/// Access cannot be granted because an existing resource exists with
|
/// Access cannot be granted because an existing resource exists with
|
||||||
/// the same name or address; the associated error type SHOULD be
|
/// the same name or address; the associated error type SHOULD be
|
||||||
/// "cancel".
|
/// "cancel".
|
||||||
Conflict => "conflict",
|
#[xml(name = "conflict")]
|
||||||
|
Conflict,
|
||||||
|
|
||||||
/// The feature represented in the XML stanza is not implemented by the
|
/// The feature represented in the XML stanza is not implemented by the
|
||||||
/// intended recipient or an intermediate server and therefore the
|
/// intended recipient or an intermediate server and therefore the
|
||||||
/// stanza cannot be processed (e.g., the entity understands the
|
/// stanza cannot be processed (e.g., the entity understands the
|
||||||
/// namespace but does not recognize the element name); the associated
|
/// namespace but does not recognize the element name); the associated
|
||||||
/// error type SHOULD be "cancel" or "modify".
|
/// error type SHOULD be "cancel" or "modify".
|
||||||
FeatureNotImplemented => "feature-not-implemented",
|
#[xml(name = "feature-not-implemented")]
|
||||||
|
FeatureNotImplemented,
|
||||||
|
|
||||||
/// The requesting entity does not possess the necessary permissions to
|
/// The requesting entity does not possess the necessary permissions to
|
||||||
/// perform an action that only certain authorized roles or individuals
|
/// perform an action that only certain authorized roles or individuals
|
||||||
/// are allowed to complete (i.e., it typically relates to
|
/// are allowed to complete (i.e., it typically relates to
|
||||||
/// authorization rather than authentication); the associated error
|
/// authorization rather than authentication); the associated error
|
||||||
/// type SHOULD be "auth".
|
/// type SHOULD be "auth".
|
||||||
Forbidden => "forbidden",
|
#[xml(name = "forbidden")]
|
||||||
|
Forbidden,
|
||||||
|
|
||||||
/// The recipient or server can no longer be contacted at this address,
|
/// The recipient or server can no longer be contacted at this address,
|
||||||
/// typically on a permanent basis (as opposed to the \<redirect/\> error
|
/// typically on a permanent basis (as opposed to the \<redirect/\> error
|
||||||
/// condition, which is used for temporary addressing failures); the
|
/// condition, which is used for temporary addressing failures); the
|
||||||
/// associated error type SHOULD be "cancel" and the error stanza
|
/// associated error type SHOULD be "cancel" and the error stanza
|
||||||
/// SHOULD include a new address (if available) as the XML character
|
/// SHOULD include a new address (if available) as the XML character
|
||||||
/// data of the \<gone/\> element (which MUST be a Uniform Resource
|
/// data of the \<gone/\> element (which MUST be a Uniform Resource
|
||||||
/// Identifier (URI) or Internationalized Resource Identifier (IRI) at
|
/// Identifier (URI) or Internationalized Resource Identifier (IRI) at
|
||||||
/// which the entity can be contacted, typically an XMPP IRI as
|
/// which the entity can be contacted, typically an XMPP IRI as
|
||||||
/// specified in [XMPP‑URI](https://www.rfc-editor.org/rfc/rfc5122)).
|
/// specified in [XMPP‑URI](https://www.rfc-editor.org/rfc/rfc5122)).
|
||||||
Gone => "gone",
|
#[xml(name = "gone")]
|
||||||
|
Gone {
|
||||||
|
/// The new address of the entity for which the error was returned,
|
||||||
|
/// if available.
|
||||||
|
#[xml(text(codec = EmptyAsNone))]
|
||||||
|
new_address: Option<String>,
|
||||||
|
},
|
||||||
|
|
||||||
/// The server has experienced a misconfiguration or other internal
|
/// The server has experienced a misconfiguration or other internal
|
||||||
/// error that prevents it from processing the stanza; the associated
|
/// error that prevents it from processing the stanza; the associated
|
||||||
/// error type SHOULD be "cancel".
|
/// error type SHOULD be "cancel".
|
||||||
InternalServerError => "internal-server-error",
|
#[xml(name = "internal-server-error")]
|
||||||
|
InternalServerError,
|
||||||
|
|
||||||
/// The addressed JID or item requested cannot be found; the associated
|
/// The addressed JID or item requested cannot be found; the associated
|
||||||
/// error type SHOULD be "cancel".
|
/// error type SHOULD be "cancel".
|
||||||
ItemNotFound => "item-not-found",
|
#[xml(name = "item-not-found")]
|
||||||
|
ItemNotFound,
|
||||||
|
|
||||||
/// The sending entity has provided (e.g., during resource binding) or
|
/// The sending entity has provided (e.g., during resource binding) or
|
||||||
/// communicated (e.g., in the 'to' address of a stanza) an XMPP
|
/// communicated (e.g., in the 'to' address of a stanza) an XMPP
|
||||||
/// address or aspect thereof that violates the rules defined in
|
/// address or aspect thereof that violates the rules defined in
|
||||||
/// [XMPP‑ADDR]; the associated error type SHOULD be "modify".
|
/// [XMPP‑ADDR]; the associated error type SHOULD be "modify".
|
||||||
JidMalformed => "jid-malformed",
|
#[xml(name = "jid-malformed")]
|
||||||
|
JidMalformed,
|
||||||
|
|
||||||
/// The recipient or server understands the request but cannot process
|
/// The recipient or server understands the request but cannot process
|
||||||
/// it because the request does not meet criteria defined by the
|
/// it because the request does not meet criteria defined by the
|
||||||
/// recipient or server (e.g., a request to subscribe to information
|
/// recipient or server (e.g., a request to subscribe to information
|
||||||
/// that does not simultaneously include configuration parameters
|
/// that does not simultaneously include configuration parameters
|
||||||
/// needed by the recipient); the associated error type SHOULD be
|
/// needed by the recipient); the associated error type SHOULD be
|
||||||
/// "modify".
|
/// "modify".
|
||||||
NotAcceptable => "not-acceptable",
|
#[xml(name = "not-acceptable")]
|
||||||
|
NotAcceptable,
|
||||||
|
|
||||||
/// The recipient or server does not allow any entity to perform the
|
/// The recipient or server does not allow any entity to perform the
|
||||||
/// action (e.g., sending to entities at a blacklisted domain); the
|
/// action (e.g., sending to entities at a blacklisted domain); the
|
||||||
/// associated error type SHOULD be "cancel".
|
/// associated error type SHOULD be "cancel".
|
||||||
NotAllowed => "not-allowed",
|
#[xml(name = "not-allowed")]
|
||||||
|
NotAllowed,
|
||||||
|
|
||||||
/// The sender needs to provide credentials before being allowed to
|
/// The sender needs to provide credentials before being allowed to
|
||||||
/// perform the action, or has provided improper credentials (the name
|
/// perform the action, or has provided improper credentials (the name
|
||||||
/// "not-authorized", which was borrowed from the "401 Unauthorized"
|
/// "not-authorized", which was borrowed from the "401 Unauthorized"
|
||||||
/// error of HTTP, might lead the reader to think that this condition
|
/// error of HTTP, might lead the reader to think that this condition
|
||||||
/// relates to authorization, but instead it is typically used in
|
/// relates to authorization, but instead it is typically used in
|
||||||
/// relation to authentication); the associated error type SHOULD be
|
/// relation to authentication); the associated error type SHOULD be
|
||||||
/// "auth".
|
/// "auth".
|
||||||
NotAuthorized => "not-authorized",
|
#[xml(name = "not-authorized")]
|
||||||
|
NotAuthorized,
|
||||||
|
|
||||||
/// The entity has violated some local service policy (e.g., a message
|
/// The entity has violated some local service policy (e.g., a message
|
||||||
/// contains words that are prohibited by the service) and the server
|
/// contains words that are prohibited by the service) and the server
|
||||||
/// MAY choose to specify the policy in the \<text/\> element or in an
|
/// MAY choose to specify the policy in the \<text/\> element or in an
|
||||||
/// application-specific condition element; the associated error type
|
/// application-specific condition element; the associated error type
|
||||||
/// SHOULD be "modify" or "wait" depending on the policy being
|
/// SHOULD be "modify" or "wait" depending on the policy being
|
||||||
/// violated.
|
/// violated.
|
||||||
PolicyViolation => "policy-violation",
|
#[xml(name = "policy-violation")]
|
||||||
|
PolicyViolation,
|
||||||
|
|
||||||
/// The intended recipient is temporarily unavailable, undergoing
|
/// The intended recipient is temporarily unavailable, undergoing
|
||||||
/// maintenance, etc.; the associated error type SHOULD be "wait".
|
/// maintenance, etc.; the associated error type SHOULD be "wait".
|
||||||
RecipientUnavailable => "recipient-unavailable",
|
#[xml(name = "recipient-unavailable")]
|
||||||
|
RecipientUnavailable,
|
||||||
|
|
||||||
/// The recipient or server is redirecting requests for this
|
/// The recipient or server is redirecting requests for this
|
||||||
/// information to another entity, typically in a temporary fashion (as
|
/// information to another entity, typically in a temporary fashion (as
|
||||||
/// opposed to the \<gone/\> error condition, which is used for permanent
|
/// opposed to the \<gone/\> error condition, which is used for permanent
|
||||||
/// addressing failures); the associated error type SHOULD be "modify"
|
/// addressing failures); the associated error type SHOULD be "modify"
|
||||||
/// and the error stanza SHOULD contain the alternate address in the
|
/// and the error stanza SHOULD contain the alternate address in the
|
||||||
/// XML character data of the \<redirect/\> element (which MUST be a URI
|
/// XML character data of the \<redirect/\> element (which MUST be a URI
|
||||||
/// or IRI with which the sender can communicate, typically an XMPP IRI
|
/// or IRI with which the sender can communicate, typically an XMPP IRI
|
||||||
/// as specified in [XMPP‑URI](https://xmpp.org/rfcs/rfc5122.html)).
|
/// as specified in [XMPP‑URI](https://xmpp.org/rfcs/rfc5122.html)).
|
||||||
Redirect => "redirect",
|
#[xml(name = "redirect")]
|
||||||
|
Redirect {
|
||||||
|
/// The new address of the entity for which the error was returned,
|
||||||
|
/// if available.
|
||||||
|
#[xml(text(codec = EmptyAsNone))]
|
||||||
|
new_address: Option<String>,
|
||||||
|
},
|
||||||
|
|
||||||
/// The requesting entity is not authorized to access the requested
|
/// The requesting entity is not authorized to access the requested
|
||||||
/// service because prior registration is necessary (examples of prior
|
/// service because prior registration is necessary (examples of prior
|
||||||
/// registration include members-only rooms in XMPP multi-user chat
|
/// registration include members-only rooms in XMPP multi-user chat
|
||||||
/// [XEP‑0045] and gateways to non-XMPP instant messaging services,
|
/// [XEP‑0045] and gateways to non-XMPP instant messaging services,
|
||||||
/// which traditionally required registration in order to use the
|
/// which traditionally required registration in order to use the
|
||||||
/// gateway [XEP‑0100]); the associated error type SHOULD be "auth".
|
/// gateway [XEP‑0100]); the associated error type SHOULD be "auth".
|
||||||
RegistrationRequired => "registration-required",
|
#[xml(name = "registration-required")]
|
||||||
|
RegistrationRequired,
|
||||||
|
|
||||||
/// A remote server or service specified as part or all of the JID of
|
/// A remote server or service specified as part or all of the JID of
|
||||||
/// the intended recipient does not exist or cannot be resolved (e.g.,
|
/// the intended recipient does not exist or cannot be resolved (e.g.,
|
||||||
/// there is no _xmpp-server._tcp DNS SRV record, the A or AAAA
|
/// there is no _xmpp-server._tcp DNS SRV record, the A or AAAA
|
||||||
/// fallback resolution fails, or A/AAAA lookups succeed but there is
|
/// fallback resolution fails, or A/AAAA lookups succeed but there is
|
||||||
/// no response on the IANA-registered port 5269); the associated error
|
/// no response on the IANA-registered port 5269); the associated error
|
||||||
/// type SHOULD be "cancel".
|
/// type SHOULD be "cancel".
|
||||||
RemoteServerNotFound => "remote-server-not-found",
|
#[xml(name = "remote-server-not-found")]
|
||||||
|
RemoteServerNotFound,
|
||||||
|
|
||||||
/// A remote server or service specified as part or all of the JID of
|
/// A remote server or service specified as part or all of the JID of
|
||||||
/// the intended recipient (or needed to fulfill a request) was
|
/// the intended recipient (or needed to fulfill a request) was
|
||||||
/// resolved but communications could not be established within a
|
/// resolved but communications could not be established within a
|
||||||
/// reasonable amount of time (e.g., an XML stream cannot be
|
/// reasonable amount of time (e.g., an XML stream cannot be
|
||||||
/// established at the resolved IP address and port, or an XML stream
|
/// established at the resolved IP address and port, or an XML stream
|
||||||
/// can be established but stream negotiation fails because of problems
|
/// can be established but stream negotiation fails because of problems
|
||||||
/// with TLS, SASL, Server Dialback, etc.); the associated error type
|
/// with TLS, SASL, Server Dialback, etc.); the associated error type
|
||||||
/// SHOULD be "wait" (unless the error is of a more permanent nature,
|
/// SHOULD be "wait" (unless the error is of a more permanent nature,
|
||||||
/// e.g., the remote server is found but it cannot be authenticated or
|
/// e.g., the remote server is found but it cannot be authenticated or
|
||||||
/// it violates security policies).
|
/// it violates security policies).
|
||||||
RemoteServerTimeout => "remote-server-timeout",
|
#[xml(name = "remote-server-timeout")]
|
||||||
|
RemoteServerTimeout,
|
||||||
|
|
||||||
/// The server or recipient is busy or lacks the system resources
|
/// The server or recipient is busy or lacks the system resources
|
||||||
/// necessary to service the request; the associated error type SHOULD
|
/// necessary to service the request; the associated error type SHOULD
|
||||||
/// be "wait".
|
/// be "wait".
|
||||||
ResourceConstraint => "resource-constraint",
|
#[xml(name = "resource-constraint")]
|
||||||
|
ResourceConstraint,
|
||||||
|
|
||||||
/// The server or recipient does not currently provide the requested
|
/// The server or recipient does not currently provide the requested
|
||||||
/// service; the associated error type SHOULD be "cancel".
|
/// service; the associated error type SHOULD be "cancel".
|
||||||
ServiceUnavailable => "service-unavailable",
|
#[xml(name = "service-unavailable")]
|
||||||
|
ServiceUnavailable,
|
||||||
|
|
||||||
/// The requesting entity is not authorized to access the requested
|
/// The requesting entity is not authorized to access the requested
|
||||||
/// service because a prior subscription is necessary (examples of
|
/// service because a prior subscription is necessary (examples of
|
||||||
/// prior subscription include authorization to receive presence
|
/// prior subscription include authorization to receive presence
|
||||||
/// information as defined in [XMPP‑IM] and opt-in data feeds for XMPP
|
/// information as defined in [XMPP‑IM] and opt-in data feeds for XMPP
|
||||||
/// publish-subscribe as defined in [XEP‑0060]); the associated error
|
/// publish-subscribe as defined in [XEP‑0060]); the associated error
|
||||||
/// type SHOULD be "auth".
|
/// type SHOULD be "auth".
|
||||||
SubscriptionRequired => "subscription-required",
|
#[xml(name = "subscription-required")]
|
||||||
|
SubscriptionRequired,
|
||||||
|
|
||||||
/// The error condition is not one of those defined by the other
|
/// The error condition is not one of those defined by the other
|
||||||
/// conditions in this list; any error type can be associated with this
|
/// conditions in this list; any error type can be associated with this
|
||||||
/// condition, and it SHOULD NOT be used except in conjunction with an
|
/// condition, and it SHOULD NOT be used except in conjunction with an
|
||||||
/// application-specific condition.
|
/// application-specific condition.
|
||||||
UndefinedCondition => "undefined-condition",
|
#[xml(name = "undefined-condition")]
|
||||||
|
UndefinedCondition,
|
||||||
|
|
||||||
/// The recipient or server understood the request but was not
|
/// The recipient or server understood the request but was not
|
||||||
/// expecting it at this time (e.g., the request was out of order); the
|
/// expecting it at this time (e.g., the request was out of order); the
|
||||||
/// associated error type SHOULD be "wait" or "modify".
|
/// associated error type SHOULD be "wait" or "modify".
|
||||||
UnexpectedRequest => "unexpected-request",
|
#[xml(name = "unexpected-request")]
|
||||||
}
|
UnexpectedRequest,
|
||||||
);
|
}
|
||||||
|
|
||||||
type Lang = String;
|
type Lang = String;
|
||||||
|
|
||||||
|
|
@ -211,11 +244,6 @@ pub struct StanzaError {
|
||||||
|
|
||||||
/// A protocol-specific extension for this error.
|
/// A protocol-specific extension for this error.
|
||||||
pub other: Option<Element>,
|
pub other: Option<Element>,
|
||||||
|
|
||||||
/// May include an alternate address if `defined_condition` is `Gone` or `Redirect`. It is
|
|
||||||
/// a Uniform Resource Identifier [URI] or Internationalized Resource Identifier [IRI] at
|
|
||||||
/// which the entity can be contacted, typically an XMPP IRI as specified in [XMPP‑URI]
|
|
||||||
pub alternate_address: Option<String>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MessagePayload for StanzaError {}
|
impl MessagePayload for StanzaError {}
|
||||||
|
|
@ -243,7 +271,6 @@ impl StanzaError {
|
||||||
map
|
map
|
||||||
},
|
},
|
||||||
other: None,
|
other: None,
|
||||||
alternate_address: None,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -263,7 +290,6 @@ impl TryFrom<Element> for StanzaError {
|
||||||
defined_condition: DefinedCondition::UndefinedCondition,
|
defined_condition: DefinedCondition::UndefinedCondition,
|
||||||
texts: BTreeMap::new(),
|
texts: BTreeMap::new(),
|
||||||
other: None,
|
other: None,
|
||||||
alternate_address: None,
|
|
||||||
};
|
};
|
||||||
let mut defined_condition = None;
|
let mut defined_condition = None;
|
||||||
|
|
||||||
|
|
@ -286,16 +312,7 @@ impl TryFrom<Element> for StanzaError {
|
||||||
}
|
}
|
||||||
check_no_children!(child, "defined-condition");
|
check_no_children!(child, "defined-condition");
|
||||||
check_no_attributes!(child, "defined-condition");
|
check_no_attributes!(child, "defined-condition");
|
||||||
let condition = DefinedCondition::try_from(child.clone())?;
|
defined_condition = Some(DefinedCondition::try_from(child.clone())?);
|
||||||
|
|
||||||
if condition == DefinedCondition::Gone || condition == DefinedCondition::Redirect {
|
|
||||||
stanza_error.alternate_address = child.nodes().find_map(|node| {
|
|
||||||
let Node::Text(text) = node else { return None };
|
|
||||||
Some(text.to_string())
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
defined_condition = Some(condition);
|
|
||||||
} else {
|
} else {
|
||||||
if stanza_error.other.is_some() {
|
if stanza_error.other.is_some() {
|
||||||
return Err(
|
return Err(
|
||||||
|
|
@ -336,16 +353,16 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_size() {
|
fn test_size() {
|
||||||
assert_size!(ErrorType, 1);
|
assert_size!(ErrorType, 1);
|
||||||
assert_size!(DefinedCondition, 1);
|
assert_size!(DefinedCondition, 16);
|
||||||
assert_size!(StanzaError, 104);
|
assert_size!(StanzaError, 108);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "64")]
|
#[cfg(target_pointer_width = "64")]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_size() {
|
fn test_size() {
|
||||||
assert_size!(ErrorType, 1);
|
assert_size!(ErrorType, 1);
|
||||||
assert_size!(DefinedCondition, 1);
|
assert_size!(DefinedCondition, 32);
|
||||||
assert_size!(StanzaError, 208);
|
assert_size!(StanzaError, 216);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -446,10 +463,11 @@ mod tests {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let error = StanzaError::try_from(elem).unwrap();
|
let error = StanzaError::try_from(elem).unwrap();
|
||||||
assert_eq!(error.type_, ErrorType::Cancel);
|
assert_eq!(error.type_, ErrorType::Cancel);
|
||||||
assert_eq!(error.defined_condition, DefinedCondition::Gone);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
error.alternate_address,
|
error.defined_condition,
|
||||||
Some("xmpp:room@muc.example.org?join".to_string())
|
DefinedCondition::Gone {
|
||||||
|
new_address: Some("xmpp:room@muc.example.org?join".to_string()),
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -465,8 +483,10 @@ mod tests {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let error = StanzaError::try_from(elem).unwrap();
|
let error = StanzaError::try_from(elem).unwrap();
|
||||||
assert_eq!(error.type_, ErrorType::Cancel);
|
assert_eq!(error.type_, ErrorType::Cancel);
|
||||||
assert_eq!(error.defined_condition, DefinedCondition::Gone);
|
assert_eq!(
|
||||||
assert_eq!(error.alternate_address, None);
|
error.defined_condition,
|
||||||
|
DefinedCondition::Gone { new_address: None }
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -481,10 +501,11 @@ mod tests {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let error = StanzaError::try_from(elem).unwrap();
|
let error = StanzaError::try_from(elem).unwrap();
|
||||||
assert_eq!(error.type_, ErrorType::Modify);
|
assert_eq!(error.type_, ErrorType::Modify);
|
||||||
assert_eq!(error.defined_condition, DefinedCondition::Redirect);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
error.alternate_address,
|
error.defined_condition,
|
||||||
Some("xmpp:characters@conference.example.org".to_string())
|
DefinedCondition::Redirect {
|
||||||
|
new_address: Some("xmpp:characters@conference.example.org".to_string()),
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -500,7 +521,9 @@ mod tests {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let error = StanzaError::try_from(elem).unwrap();
|
let error = StanzaError::try_from(elem).unwrap();
|
||||||
assert_eq!(error.type_, ErrorType::Modify);
|
assert_eq!(error.type_, ErrorType::Modify);
|
||||||
assert_eq!(error.defined_condition, DefinedCondition::Redirect);
|
assert_eq!(
|
||||||
assert_eq!(error.alternate_address, None);
|
error.defined_condition,
|
||||||
|
DefinedCondition::Redirect { new_address: None }
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue