From 32f427a73c4aa24d07ccf9d13beefd92e0d36038 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Fri, 24 Nov 2017 05:24:12 +0000 Subject: [PATCH] muc/user: Generate Reason automatically. --- src/muc/user.rs | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/src/muc/user.rs b/src/muc/user.rs index fb30967..6c25209 100644 --- a/src/muc/user.rs +++ b/src/muc/user.rs @@ -196,34 +196,7 @@ generate_element_with_only_attributes!(Continue, "continue", ns::MUC_USER, [ thread: Option = "thread" => optional, ]); -#[derive(Debug, Clone, PartialEq)] -pub struct Reason(String); - -impl TryFrom for Reason { - type Err = Error; - - fn try_from(elem: Element) -> Result { - if !elem.is("reason", ns::MUC_USER) { - return Err(Error::ParseError("This is not a reason element.")); - } - for _ in elem.children() { - return Err(Error::ParseError("Unknown child in reason element.")); - } - for _ in elem.attrs() { - return Err(Error::ParseError("Unknown attribute in reason element.")); - } - Ok(Reason(elem.text())) - } -} - -impl From for Element { - fn from(reason: Reason) -> Element { - Element::builder("reason") - .ns(ns::MUC_USER) - .append(reason.0) - .build() - } -} +generate_elem_id!(Reason, "reason", ns::MUC_USER); generate_attribute!(Affiliation, "affiliation", { Owner => "owner",