diff --git a/src/component.rs b/src/component.rs new file mode 100644 index 0000000..9c54118 --- /dev/null +++ b/src/component.rs @@ -0,0 +1,32 @@ +// Copyright (c) 2018 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 try_from::TryFrom; + +use minidom::Element; +use error::Error; +use helpers::Base64; +use ns; + +generate_element_with_text!(Handshake, "handshake", ns::COMPONENT, + data: Base64> +); + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_simple() { + let elem: Element = "".parse().unwrap(); + let handshake = Handshake::try_from(elem).unwrap(); + assert!(handshake.data.is_empty()); + + let elem: Element = "AAAA".parse().unwrap(); + let handshake = Handshake::try_from(elem).unwrap(); + assert_eq!(handshake.data, b"\0\0\0"); + } +} diff --git a/src/lib.rs b/src/lib.rs index 7d9091b..e420e23 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -101,6 +101,9 @@ pub mod version; /// XEP-0107: User Mood pub mod mood; +/// XEP-0114: Jabber Component Protocol +pub mod component; + /// XEP-0115: Entity Capabilities pub mod caps; diff --git a/src/ns.rs b/src/ns.rs index af77fe3..2227886 100644 --- a/src/ns.rs +++ b/src/ns.rs @@ -65,6 +65,9 @@ pub const MOOD: &str = "http://jabber.org/protocol/mood"; /// XEP-0114: Jabber Component Protocol pub const COMPONENT_ACCEPT: &str = "jabber:component:accept"; +/// XEP-0114: Jabber Component Protocol +pub const COMPONENT: &str = "jabber:component:accept"; + /// XEP-0115: Entity Capabilities pub const CAPS: &str = "http://jabber.org/protocol/caps";