diff --git a/src/iq.rs b/src/iq.rs index b621689..4362475 100644 --- a/src/iq.rs +++ b/src/iq.rs @@ -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 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(), } } } diff --git a/src/message.rs b/src/message.rs index a900502..96153cf 100644 --- a/src/message.rs +++ b/src/message.rs @@ -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 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(), } } } diff --git a/src/presence.rs b/src/presence.rs index 67ca5fa..7eb53b4 100644 --- a/src/presence.rs +++ b/src/presence.rs @@ -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 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(), } } }