mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
stream: Document this module.
This commit is contained in:
parent
4ccf92081c
commit
c6ca22e264
1 changed files with 29 additions and 10 deletions
|
@ -4,20 +4,32 @@
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// 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/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
#![allow(missing_docs)]
|
|
||||||
|
|
||||||
use jid::Jid;
|
use jid::Jid;
|
||||||
|
|
||||||
generate_element!(Stream, "stream", STREAM,
|
generate_element!(
|
||||||
attributes: [
|
/// The stream opening for client-server communications.
|
||||||
from: Option<Jid> = "from" => optional,
|
Stream, "stream", STREAM,
|
||||||
to: Option<Jid> = "to" => optional,
|
attributes: [
|
||||||
id: Option<String> = "id" => optional,
|
/// The JID of the entity opening this stream.
|
||||||
version: Option<String> = "version" => optional,
|
from: Option<Jid> = "from" => optional,
|
||||||
xml_lang: Option<String> = "xml:lang" => optional,
|
|
||||||
]);
|
/// The JID of the entity receiving this stream opening.
|
||||||
|
to: Option<Jid> = "to" => optional,
|
||||||
|
|
||||||
|
/// The id of the stream, used for authentication challenges.
|
||||||
|
id: Option<String> = "id" => optional,
|
||||||
|
|
||||||
|
/// The XMPP version used during this stream.
|
||||||
|
version: Option<String> = "version" => optional,
|
||||||
|
|
||||||
|
/// The default human language for all subsequent stanzas, which will
|
||||||
|
/// be transmitted to other entities for better localisation.
|
||||||
|
xml_lang: Option<String> = "xml:lang" => optional,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
impl Stream {
|
impl Stream {
|
||||||
|
/// Creates a simple client→server `<stream:stream>` element.
|
||||||
pub fn new(to: Jid) -> Stream {
|
pub fn new(to: Jid) -> Stream {
|
||||||
Stream {
|
Stream {
|
||||||
from: None,
|
from: None,
|
||||||
|
@ -28,21 +40,28 @@ impl Stream {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the [@from](#structfield.from) attribute on this `<stream:stream>`
|
||||||
|
/// element.
|
||||||
pub fn with_from(mut self, from: Jid) -> Stream {
|
pub fn with_from(mut self, from: Jid) -> Stream {
|
||||||
self.from = Some(from);
|
self.from = Some(from);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the [@id](#structfield.id) attribute on this `<stream:stream>`
|
||||||
|
/// element.
|
||||||
pub fn with_id(mut self, id: String) -> Stream {
|
pub fn with_id(mut self, id: String) -> Stream {
|
||||||
self.id = Some(id);
|
self.id = Some(id);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the [@xml:lang](#structfield.xml_lang) attribute on this
|
||||||
|
/// `<stream:stream>` element.
|
||||||
pub fn with_lang(mut self, xml_lang: String) -> Stream {
|
pub fn with_lang(mut self, xml_lang: String) -> Stream {
|
||||||
self.xml_lang = Some(xml_lang);
|
self.xml_lang = Some(xml_lang);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Checks whether the version matches the expected one.
|
||||||
pub fn is_version(&self, version: &str) -> bool {
|
pub fn is_version(&self, version: &str) -> bool {
|
||||||
match self.version {
|
match self.version {
|
||||||
None => false,
|
None => false,
|
||||||
|
|
Loading…
Reference in a new issue