diff --git a/src/websocket.rs b/src/websocket.rs index 2f99e31..102690c 100644 --- a/src/websocket.rs +++ b/src/websocket.rs @@ -4,20 +4,32 @@ // 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/. -#![allow(missing_docs)] - use jid::Jid; -generate_element!(Open, "open", WEBSOCKET, -attributes: [ - from: Option = "from" => optional, - to: Option = "to" => optional, - id: Option = "id" => optional, - version: Option = "version" => optional, - xml_lang: Option = "xml:lang" => optional, -]); +generate_element!( + /// The stream opening for WebSocket. + Open, "open", WEBSOCKET, + attributes: [ + /// The JID of the entity opening this stream. + from: Option = "from" => optional, + + /// The JID of the entity receiving this stream opening. + to: Option = "to" => optional, + + /// The id of the stream, used for authentication challenges. + id: Option = "id" => optional, + + /// The XMPP version used during this stream. + version: Option = "version" => optional, + + /// The default human language for all subsequent stanzas, which will + /// be transmitted to other entities for better localisation. + xml_lang: Option = "xml:lang" => optional, + ] +); impl Open { + /// Creates a simple client→server `` element. pub fn new(to: Jid) -> Open { Open { from: None, @@ -28,21 +40,27 @@ impl Open { } } + /// Sets the [@from](#structfield.from) attribute on this `` + /// element. pub fn with_from(mut self, from: Jid) -> Open { self.from = Some(from); self } + /// Sets the [@id](#structfield.id) attribute on this `` element. pub fn with_id(mut self, id: String) -> Open { self.id = Some(id); self } + /// Sets the [@xml:lang](#structfield.xml_lang) attribute on this `` + /// element. pub fn with_lang(mut self, xml_lang: String) -> Open { self.xml_lang = Some(xml_lang); self } + /// Checks whether the version matches the expected one. pub fn is_version(&self, version: &str) -> bool { match self.version { None => false,