From 414210796507c03c71ded2dfda77a8a60da25a48 Mon Sep 17 00:00:00 2001
From: Emmanuel Gil Peyrot
Date: Sat, 6 May 2017 21:38:23 +0100
Subject: [PATCH] message: Merge body in this module, and make it support
xml:lang.
---
src/body.rs | 86 --------------------------------------------------
src/lib.rs | 3 --
src/message.rs | 81 +++++++++++++++++++++++++++++++----------------
3 files changed, 53 insertions(+), 117 deletions(-)
delete mode 100644 src/body.rs
diff --git a/src/body.rs b/src/body.rs
deleted file mode 100644
index 8f23b56..0000000
--- a/src/body.rs
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright (c) 2017 Emmanuel Gil Peyrot
-//
-// This Source Code Form is subject to the terms of the Mozilla Public
-// License, v. 2.0. If a copy of the MPL was not distributed with this
-// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-use minidom::Element;
-
-use error::Error;
-
-use ns;
-
-pub type Body = String;
-
-pub fn parse_body(root: &Element) -> Result {
- // TODO: also support components and servers.
- if !root.is("body", ns::JABBER_CLIENT) {
- return Err(Error::ParseError("This is not a body element."));
- }
- for _ in root.children() {
- return Err(Error::ParseError("Unknown child in body element."));
- }
- Ok(root.text())
-}
-
-pub fn serialise(body: &Body) -> Element {
- Element::builder("body")
- .ns(ns::JABBER_CLIENT)
- .append(body.to_owned())
- .build()
-}
-
-#[cfg(test)]
-mod tests {
- use minidom::Element;
- use error::Error;
- use body;
- use ns;
-
- #[test]
- fn test_simple() {
- let elem: Element = "".parse().unwrap();
- body::parse_body(&elem).unwrap();
- }
-
- #[test]
- fn test_invalid() {
- let elem: Element = "".parse().unwrap();
- let error = body::parse_body(&elem).unwrap_err();
- let message = match error {
- Error::ParseError(string) => string,
- _ => panic!(),
- };
- assert_eq!(message, "This is not a body element.");
- }
-
- #[test]
- fn test_invalid_child() {
- let elem: Element = "
".parse().unwrap();
- let error = body::parse_body(&elem).unwrap_err();
- let message = match error {
- Error::ParseError(string) => string,
- _ => panic!(),
- };
- assert_eq!(message, "Unknown child in body element.");
- }
-
- #[test]
- #[ignore]
- fn test_invalid_attribute() {
- let elem: Element = "