diff --git a/xmpp-parsers/src/jingle.rs b/xmpp-parsers/src/jingle.rs index 5db03c06..1e357f30 100644 --- a/xmpp-parsers/src/jingle.rs +++ b/xmpp-parsers/src/jingle.rs @@ -15,6 +15,7 @@ use crate::Element; use jid::Jid; use std::collections::BTreeMap; use std::convert::TryFrom; +use std::fmt; use std::str::FromStr; generate_attribute!( @@ -472,6 +473,18 @@ pub struct ReasonElement { pub texts: BTreeMap, } +impl fmt::Display for ReasonElement { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + write!(fmt, "{}", Element::from(self.reason.clone()).name())?; + if let Some(text) = self.texts.get("en") { + write!(fmt, ": {}", text)?; + } else if let Some(text) = self.texts.get("") { + write!(fmt, ": {}", text)?; + } + Ok(()) + } +} + impl TryFrom for ReasonElement { type Error = Error;