mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
message, iq, presence: Return an Unknown instead of an error when the element is unknown.
This commit is contained in:
parent
dcb7ac8db2
commit
2b8bcebfd9
3 changed files with 15 additions and 3 deletions
|
@ -29,6 +29,8 @@ pub enum IqPayload {
|
||||||
IBB(IBB),
|
IBB(IBB),
|
||||||
Jingle(Jingle),
|
Jingle(Jingle),
|
||||||
Ping(Ping),
|
Ping(Ping),
|
||||||
|
|
||||||
|
Unknown(Element),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> TryFrom<&'a Element> for IqPayload {
|
impl<'a> TryFrom<&'a Element> for IqPayload {
|
||||||
|
@ -50,7 +52,7 @@ impl<'a> TryFrom<&'a Element> for IqPayload {
|
||||||
// XEP-0199
|
// XEP-0199
|
||||||
("ping", ns::PING) => IqPayload::Ping(Ping::try_from(elem)?),
|
("ping", ns::PING) => IqPayload::Ping(Ping::try_from(elem)?),
|
||||||
|
|
||||||
_ => return Err(Error::ParseError("Unknown iq payload."))
|
_ => IqPayload::Unknown(elem.clone()),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,6 +166,8 @@ impl<'a> Into<Element> for &'a IqPayload {
|
||||||
IqPayload::IBB(ref ibb) => ibb.into(),
|
IqPayload::IBB(ref ibb) => ibb.into(),
|
||||||
IqPayload::Jingle(ref jingle) => jingle.into(),
|
IqPayload::Jingle(ref jingle) => jingle.into(),
|
||||||
IqPayload::Ping(ref ping) => ping.into(),
|
IqPayload::Ping(ref ping) => ping.into(),
|
||||||
|
|
||||||
|
IqPayload::Unknown(ref elem) => elem.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,8 @@ pub enum MessagePayload {
|
||||||
MessageCorrect(Replace),
|
MessageCorrect(Replace),
|
||||||
ExplicitMessageEncryption(ExplicitMessageEncryption),
|
ExplicitMessageEncryption(ExplicitMessageEncryption),
|
||||||
StanzaId(StanzaId),
|
StanzaId(StanzaId),
|
||||||
|
|
||||||
|
Unknown(Element),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> TryFrom<&'a Element> for MessagePayload {
|
impl<'a> TryFrom<&'a Element> for MessagePayload {
|
||||||
|
@ -71,7 +73,7 @@ impl<'a> TryFrom<&'a Element> for MessagePayload {
|
||||||
// XEP-0380
|
// XEP-0380
|
||||||
("encryption", ns::EME) => MessagePayload::ExplicitMessageEncryption(ExplicitMessageEncryption::try_from(elem)?),
|
("encryption", ns::EME) => MessagePayload::ExplicitMessageEncryption(ExplicitMessageEncryption::try_from(elem)?),
|
||||||
|
|
||||||
_ => return Err(Error::ParseError("Unknown message payload."))
|
_ => MessagePayload::Unknown(elem.clone()),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,6 +89,8 @@ impl<'a> Into<Element> for &'a MessagePayload {
|
||||||
MessagePayload::MessageCorrect(ref replace) => replace.into(),
|
MessagePayload::MessageCorrect(ref replace) => replace.into(),
|
||||||
MessagePayload::ExplicitMessageEncryption(ref eme) => eme.into(),
|
MessagePayload::ExplicitMessageEncryption(ref eme) => eme.into(),
|
||||||
MessagePayload::StanzaId(ref stanza_id) => stanza_id.into(),
|
MessagePayload::StanzaId(ref stanza_id) => stanza_id.into(),
|
||||||
|
|
||||||
|
MessagePayload::Unknown(ref elem) => elem.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,8 @@ pub enum PresencePayload {
|
||||||
StanzaError(StanzaError),
|
StanzaError(StanzaError),
|
||||||
Delay(Delay),
|
Delay(Delay),
|
||||||
ECaps2(ECaps2),
|
ECaps2(ECaps2),
|
||||||
|
|
||||||
|
Unknown(Element),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> TryFrom<&'a Element> for PresencePayload {
|
impl<'a> TryFrom<&'a Element> for PresencePayload {
|
||||||
|
@ -66,7 +68,7 @@ impl<'a> TryFrom<&'a Element> for PresencePayload {
|
||||||
// XEP-0390
|
// XEP-0390
|
||||||
("c", ns::ECAPS2) => PresencePayload::ECaps2(ECaps2::try_from(elem)?),
|
("c", ns::ECAPS2) => PresencePayload::ECaps2(ECaps2::try_from(elem)?),
|
||||||
|
|
||||||
_ => return Err(Error::ParseError("Unknown presence payload."))
|
_ => PresencePayload::Unknown(elem.clone()),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,6 +79,8 @@ impl<'a> Into<Element> for &'a PresencePayload {
|
||||||
PresencePayload::StanzaError(ref stanza_error) => stanza_error.into(),
|
PresencePayload::StanzaError(ref stanza_error) => stanza_error.into(),
|
||||||
PresencePayload::Delay(ref delay) => delay.into(),
|
PresencePayload::Delay(ref delay) => delay.into(),
|
||||||
PresencePayload::ECaps2(ref ecaps2) => ecaps2.into(),
|
PresencePayload::ECaps2(ref ecaps2) => ecaps2.into(),
|
||||||
|
|
||||||
|
PresencePayload::Unknown(ref elem) => elem.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue