xmpp-parsers/jingle: Implement Display on ReasonElement.
This commit is contained in:
parent
026b7d3c12
commit
27ddad683a
1 changed files with 13 additions and 0 deletions
|
@ -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<Lang, String>,
|
||||
}
|
||||
|
||||
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<Element> for ReasonElement {
|
||||
type Error = Error;
|
||||
|
||||
|
|
Loading…
Reference in a new issue