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),
|
||||
Jingle(Jingle),
|
||||
Ping(Ping),
|
||||
|
||||
Unknown(Element),
|
||||
}
|
||||
|
||||
impl<'a> TryFrom<&'a Element> for IqPayload {
|
||||
|
@ -50,7 +52,7 @@ impl<'a> TryFrom<&'a Element> for IqPayload {
|
|||
// XEP-0199
|
||||
("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::Jingle(ref jingle) => jingle.into(),
|
||||
IqPayload::Ping(ref ping) => ping.into(),
|
||||
|
||||
IqPayload::Unknown(ref elem) => elem.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@ pub enum MessagePayload {
|
|||
MessageCorrect(Replace),
|
||||
ExplicitMessageEncryption(ExplicitMessageEncryption),
|
||||
StanzaId(StanzaId),
|
||||
|
||||
Unknown(Element),
|
||||
}
|
||||
|
||||
impl<'a> TryFrom<&'a Element> for MessagePayload {
|
||||
|
@ -71,7 +73,7 @@ impl<'a> TryFrom<&'a Element> for MessagePayload {
|
|||
// XEP-0380
|
||||
("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::ExplicitMessageEncryption(ref eme) => eme.into(),
|
||||
MessagePayload::StanzaId(ref stanza_id) => stanza_id.into(),
|
||||
|
||||
MessagePayload::Unknown(ref elem) => elem.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,8 @@ pub enum PresencePayload {
|
|||
StanzaError(StanzaError),
|
||||
Delay(Delay),
|
||||
ECaps2(ECaps2),
|
||||
|
||||
Unknown(Element),
|
||||
}
|
||||
|
||||
impl<'a> TryFrom<&'a Element> for PresencePayload {
|
||||
|
@ -66,7 +68,7 @@ impl<'a> TryFrom<&'a Element> for PresencePayload {
|
|||
// XEP-0390
|
||||
("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::Delay(ref delay) => delay.into(),
|
||||
PresencePayload::ECaps2(ref ecaps2) => ecaps2.into(),
|
||||
|
||||
PresencePayload::Unknown(ref elem) => elem.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue