Run cargo fix --edition to move to Edition 2018.
This commit is contained in:
parent
3f4586caba
commit
6b2dd8fe5e
46 changed files with 189 additions and 188 deletions
|
|
@ -11,6 +11,7 @@ repository = "https://hg.linkmauve.fr/xmpp-parsers"
|
||||||
keywords = ["xmpp", "xml"]
|
keywords = ["xmpp", "xml"]
|
||||||
categories = ["parsing", "network-programming"]
|
categories = ["parsing", "network-programming"]
|
||||||
license = "MPL-2.0"
|
license = "MPL-2.0"
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
minidom = "0.9.1"
|
minidom = "0.9.1"
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
// 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/.
|
||||||
|
|
||||||
use message::MessagePayload;
|
use crate::message::MessagePayload;
|
||||||
|
|
||||||
generate_empty_element!(
|
generate_empty_element!(
|
||||||
/// Requests the attention of the recipient.
|
/// Requests the attention of the recipient.
|
||||||
|
|
@ -18,7 +18,7 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use try_from::TryFrom;
|
use try_from::TryFrom;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_size() {
|
fn test_size() {
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,10 @@ use try_from::TryFrom;
|
||||||
|
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
|
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
use jid::Jid;
|
use jid::Jid;
|
||||||
use ns;
|
use crate::ns;
|
||||||
use iq::{IqSetPayload, IqResultPayload};
|
use crate::iq::{IqSetPayload, IqResultPayload};
|
||||||
|
|
||||||
/// The request for resource binding, which is the process by which a client
|
/// The request for resource binding, which is the process by which a client
|
||||||
/// can obtain a full JID and start exchanging on the XMPP network.
|
/// can obtain a full JID and start exchanging on the XMPP network.
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,10 @@ use try_from::TryFrom;
|
||||||
use jid::Jid;
|
use jid::Jid;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
|
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
|
|
||||||
use ns;
|
use crate::ns;
|
||||||
use iq::{IqGetPayload, IqSetPayload, IqResultPayload};
|
use crate::iq::{IqGetPayload, IqSetPayload, IqResultPayload};
|
||||||
|
|
||||||
generate_empty_element!(
|
generate_empty_element!(
|
||||||
/// The element requesting the blocklist, the result iq will contain a
|
/// The element requesting the blocklist, the result iq will contain a
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use try_from::TryFrom;
|
use try_from::TryFrom;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use compare_elements::NamespaceAwareCompare;
|
use crate::compare_elements::NamespaceAwareCompare;
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
14
src/caps.rs
14
src/caps.rs
|
|
@ -6,14 +6,14 @@
|
||||||
|
|
||||||
use try_from::TryFrom;
|
use try_from::TryFrom;
|
||||||
|
|
||||||
use presence::PresencePayload;
|
use crate::presence::PresencePayload;
|
||||||
use disco::{Feature, Identity, DiscoInfoResult, DiscoInfoQuery};
|
use crate::disco::{Feature, Identity, DiscoInfoResult, DiscoInfoQuery};
|
||||||
use data_forms::DataForm;
|
use crate::data_forms::DataForm;
|
||||||
use hashes::{Hash, Algo};
|
use crate::hashes::{Hash, Algo};
|
||||||
|
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
use ns;
|
use crate::ns;
|
||||||
use base64;
|
use base64;
|
||||||
|
|
||||||
use sha1::Sha1;
|
use sha1::Sha1;
|
||||||
|
|
@ -208,7 +208,7 @@ pub fn query_caps(caps: Caps) -> DiscoInfoQuery {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use caps;
|
use crate::caps;
|
||||||
use base64;
|
use base64;
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
// 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/.
|
||||||
|
|
||||||
use message::MessagePayload;
|
use crate::message::MessagePayload;
|
||||||
|
|
||||||
generate_element_enum!(
|
generate_element_enum!(
|
||||||
/// Enum representing chatstate elements part of the
|
/// Enum representing chatstate elements part of the
|
||||||
|
|
@ -34,8 +34,8 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use try_from::TryFrom;
|
use try_from::TryFrom;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
use ns;
|
use crate::ns;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_size() {
|
fn test_size() {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
// 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/.
|
||||||
|
|
||||||
use helpers::PlainText;
|
use crate::helpers::PlainText;
|
||||||
use sha1::Sha1;
|
use sha1::Sha1;
|
||||||
use digest::Digest;
|
use digest::Digest;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,10 @@ use try_from::TryFrom;
|
||||||
|
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
|
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
use ns;
|
use crate::ns;
|
||||||
|
|
||||||
use media_element::MediaElement;
|
use crate::media_element::MediaElement;
|
||||||
|
|
||||||
generate_element!(
|
generate_element!(
|
||||||
/// Represents one of the possible values for a list- field.
|
/// Represents one of the possible values for a list- field.
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use std::str::FromStr;
|
||||||
use minidom::{IntoAttributeValue, IntoElements, ElementEmitter};
|
use minidom::{IntoAttributeValue, IntoElements, ElementEmitter};
|
||||||
use chrono::{DateTime as ChronoDateTime, FixedOffset};
|
use chrono::{DateTime as ChronoDateTime, FixedOffset};
|
||||||
|
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
|
|
||||||
/// Implements the DateTime profile of XEP-0082, which represents a
|
/// Implements the DateTime profile of XEP-0082, which represents a
|
||||||
/// non-recurring moment in time, with an accuracy of seconds or fraction of
|
/// non-recurring moment in time, with an accuracy of seconds or fraction of
|
||||||
|
|
|
||||||
10
src/delay.rs
10
src/delay.rs
|
|
@ -4,13 +4,13 @@
|
||||||
// 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/.
|
||||||
|
|
||||||
use message::MessagePayload;
|
use crate::message::MessagePayload;
|
||||||
use presence::PresencePayload;
|
use crate::presence::PresencePayload;
|
||||||
use date::DateTime;
|
use crate::date::DateTime;
|
||||||
|
|
||||||
use jid::Jid;
|
use jid::Jid;
|
||||||
|
|
||||||
use helpers::PlainText;
|
use crate::helpers::PlainText;
|
||||||
|
|
||||||
generate_element!(
|
generate_element!(
|
||||||
/// Notes when and by whom a message got stored for later delivery.
|
/// Notes when and by whom a message got stored for later delivery.
|
||||||
|
|
@ -36,7 +36,7 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use try_from::TryFrom;
|
use try_from::TryFrom;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
|
|
|
||||||
10
src/disco.rs
10
src/disco.rs
|
|
@ -9,11 +9,11 @@ use try_from::TryFrom;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use jid::Jid;
|
use jid::Jid;
|
||||||
|
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
use ns;
|
use crate::ns;
|
||||||
|
|
||||||
use iq::{IqGetPayload, IqResultPayload};
|
use crate::iq::{IqGetPayload, IqResultPayload};
|
||||||
use data_forms::{DataForm, DataFormType};
|
use crate::data_forms::{DataForm, DataFormType};
|
||||||
|
|
||||||
generate_element!(
|
generate_element!(
|
||||||
/// Structure representing a `<query xmlns='http://jabber.org/protocol/disco#info'/>` element.
|
/// Structure representing a `<query xmlns='http://jabber.org/protocol/disco#info'/>` element.
|
||||||
|
|
@ -221,7 +221,7 @@ impl IqResultPayload for DiscoItemsResult {}
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use compare_elements::NamespaceAwareCompare;
|
use crate::compare_elements::NamespaceAwareCompare;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,12 @@
|
||||||
// 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/.
|
||||||
|
|
||||||
use presence::PresencePayload;
|
use crate::presence::PresencePayload;
|
||||||
use disco::{Feature, Identity, DiscoInfoResult, DiscoInfoQuery};
|
use crate::disco::{Feature, Identity, DiscoInfoResult, DiscoInfoQuery};
|
||||||
use data_forms::DataForm;
|
use crate::data_forms::DataForm;
|
||||||
use hashes::{Hash, Algo};
|
use crate::hashes::{Hash, Algo};
|
||||||
|
|
||||||
use ns;
|
use crate::ns;
|
||||||
use base64;
|
use base64;
|
||||||
|
|
||||||
use sha2::{Sha256, Sha512};
|
use sha2::{Sha256, Sha512};
|
||||||
|
|
@ -150,7 +150,7 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use try_from::TryFrom;
|
use try_from::TryFrom;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
// 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/.
|
||||||
|
|
||||||
use message::MessagePayload;
|
use crate::message::MessagePayload;
|
||||||
|
|
||||||
generate_element!(
|
generate_element!(
|
||||||
/// Structure representing an `<encryption xmlns='urn:xmpp:eme:0'/>` element.
|
/// Structure representing an `<encryption xmlns='urn:xmpp:eme:0'/>` element.
|
||||||
|
|
@ -26,7 +26,7 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use try_from::TryFrom;
|
use try_from::TryFrom;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@
|
||||||
// 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/.
|
||||||
|
|
||||||
use delay::Delay;
|
use crate::delay::Delay;
|
||||||
use message::Message;
|
use crate::message::Message;
|
||||||
|
|
||||||
generate_element!(
|
generate_element!(
|
||||||
/// Contains a forwarded stanza, either standalone or part of another
|
/// Contains a forwarded stanza, either standalone or part of another
|
||||||
|
|
@ -28,7 +28,7 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use try_from::TryFrom;
|
use try_from::TryFrom;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@ use std::str::FromStr;
|
||||||
|
|
||||||
use minidom::IntoAttributeValue;
|
use minidom::IntoAttributeValue;
|
||||||
|
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
|
|
||||||
use helpers::Base64;
|
use crate::helpers::Base64;
|
||||||
use base64;
|
use base64;
|
||||||
|
|
||||||
/// List of the algorithms we support, or Unknown.
|
/// List of the algorithms we support, or Unknown.
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
use base64;
|
use base64;
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
|
|
||||||
/// Codec for plain text content.
|
/// Codec for plain text content.
|
||||||
pub struct PlainText;
|
pub struct PlainText;
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@
|
||||||
// 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/.
|
||||||
|
|
||||||
use helpers::Base64;
|
use crate::helpers::Base64;
|
||||||
use iq::IqSetPayload;
|
use crate::iq::IqSetPayload;
|
||||||
|
|
||||||
generate_id!(
|
generate_id!(
|
||||||
/// An identifier matching a stream.
|
/// An identifier matching a stream.
|
||||||
|
|
@ -73,7 +73,7 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use try_from::TryFrom;
|
use try_from::TryFrom;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
use std::error::Error as StdError;
|
use std::error::Error as StdError;
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
|
|
|
||||||
10
src/ibr.rs
10
src/ibr.rs
|
|
@ -9,12 +9,12 @@ use try_from::TryFrom;
|
||||||
|
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
|
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
|
|
||||||
use iq::{IqGetPayload, IqSetPayload, IqResultPayload};
|
use crate::iq::{IqGetPayload, IqSetPayload, IqResultPayload};
|
||||||
use data_forms::DataForm;
|
use crate::data_forms::DataForm;
|
||||||
|
|
||||||
use ns;
|
use crate::ns;
|
||||||
|
|
||||||
/// Query for registering against a service.
|
/// Query for registering against a service.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|
@ -94,7 +94,7 @@ impl From<Query> for Element {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use compare_elements::NamespaceAwareCompare;
|
use crate::compare_elements::NamespaceAwareCompare;
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@
|
||||||
// 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/.
|
||||||
|
|
||||||
use presence::PresencePayload;
|
use crate::presence::PresencePayload;
|
||||||
use date::DateTime;
|
use crate::date::DateTime;
|
||||||
|
|
||||||
generate_element!(
|
generate_element!(
|
||||||
/// Represents the last time the user interacted with their system.
|
/// Represents the last time the user interacted with their system.
|
||||||
|
|
@ -23,7 +23,7 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use try_from::TryFrom;
|
use try_from::TryFrom;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::error::Error as StdError;
|
use std::error::Error as StdError;
|
||||||
|
|
||||||
|
|
|
||||||
12
src/iq.rs
12
src/iq.rs
|
|
@ -12,11 +12,11 @@ use minidom::IntoAttributeValue;
|
||||||
|
|
||||||
use jid::Jid;
|
use jid::Jid;
|
||||||
|
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
|
|
||||||
use ns;
|
use crate::ns;
|
||||||
|
|
||||||
use stanza_error::StanzaError;
|
use crate::stanza_error::StanzaError;
|
||||||
|
|
||||||
/// Should be implemented on every known payload of an `<iq type='get'/>`.
|
/// Should be implemented on every known payload of an `<iq type='get'/>`.
|
||||||
pub trait IqGetPayload: TryFrom<Element> + Into<Element> {}
|
pub trait IqGetPayload: TryFrom<Element> + Into<Element> {}
|
||||||
|
|
@ -222,9 +222,9 @@ impl From<Iq> for Element {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use stanza_error::{ErrorType, DefinedCondition};
|
use crate::stanza_error::{ErrorType, DefinedCondition};
|
||||||
use compare_elements::NamespaceAwareCompare;
|
use crate::compare_elements::NamespaceAwareCompare;
|
||||||
use disco::DiscoInfoQuery;
|
use crate::disco::DiscoInfoQuery;
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,9 @@ use std::str::FromStr;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use jid::Jid;
|
use jid::Jid;
|
||||||
|
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
use ns;
|
use crate::ns;
|
||||||
use iq::IqSetPayload;
|
use crate::iq::IqSetPayload;
|
||||||
|
|
||||||
generate_attribute!(
|
generate_attribute!(
|
||||||
/// The action attribute.
|
/// The action attribute.
|
||||||
|
|
|
||||||
|
|
@ -9,14 +9,14 @@ use std::str::FromStr;
|
||||||
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use hashes::Hash;
|
use crate::hashes::Hash;
|
||||||
use jingle::{Creator, ContentId};
|
use crate::jingle::{Creator, ContentId};
|
||||||
use date::DateTime;
|
use crate::date::DateTime;
|
||||||
|
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
|
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
use ns;
|
use crate::ns;
|
||||||
|
|
||||||
generate_element!(
|
generate_element!(
|
||||||
/// Represents a range in a file.
|
/// Represents a range in a file.
|
||||||
|
|
@ -345,7 +345,7 @@ generate_element!(
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use hashes::Algo;
|
use crate::hashes::Algo;
|
||||||
use base64;
|
use base64;
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
// 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/.
|
||||||
|
|
||||||
use ibb::{Stanza, StreamId};
|
use crate::ibb::{Stanza, StreamId};
|
||||||
|
|
||||||
generate_element!(
|
generate_element!(
|
||||||
/// Describes an [In-Band Bytestream](https://xmpp.org/extensions/xep-0047.html)
|
/// Describes an [In-Band Bytestream](https://xmpp.org/extensions/xep-0047.html)
|
||||||
|
|
@ -26,7 +26,7 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use try_from::TryFrom;
|
use try_from::TryFrom;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
use std::error::Error as StdError;
|
use std::error::Error as StdError;
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,11 @@ use try_from::TryFrom;
|
||||||
|
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
|
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
|
|
||||||
use jingle::SessionId;
|
use crate::jingle::SessionId;
|
||||||
|
|
||||||
use ns;
|
use crate::ns;
|
||||||
|
|
||||||
/// Defines a protocol for broadcasting Jingle requests to all of the clients
|
/// Defines a protocol for broadcasting Jingle requests to all of the clients
|
||||||
/// of a user.
|
/// of a user.
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,9 @@ use std::net::IpAddr;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use jid::Jid;
|
use jid::Jid;
|
||||||
|
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
|
|
||||||
use ns;
|
use crate::ns;
|
||||||
|
|
||||||
generate_attribute!(
|
generate_attribute!(
|
||||||
/// The type of the connection being proposed by this candidate.
|
/// The type of the connection being proposed by this candidate.
|
||||||
|
|
@ -275,7 +275,7 @@ impl From<Transport> for Element {
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use compare_elements::NamespaceAwareCompare;
|
use crate::compare_elements::NamespaceAwareCompare;
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ macro_rules! get_attr {
|
||||||
($elem:ident, $attr:tt, required, $value:ident, $func:expr) => (
|
($elem:ident, $attr:tt, required, $value:ident, $func:expr) => (
|
||||||
match $elem.attr($attr) {
|
match $elem.attr($attr) {
|
||||||
Some($value) => $func,
|
Some($value) => $func,
|
||||||
None => return Err(::error::Error::ParseError(concat!("Required attribute '", $attr, "' missing."))),
|
None => return Err(crate::error::Error::ParseError(concat!("Required attribute '", $attr, "' missing."))),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
($elem:ident, $attr:tt, default, $value:ident, $func:expr) => (
|
($elem:ident, $attr:tt, default, $value:ident, $func:expr) => (
|
||||||
|
|
@ -52,11 +52,11 @@ macro_rules! generate_attribute {
|
||||||
),+
|
),+
|
||||||
}
|
}
|
||||||
impl ::std::str::FromStr for $elem {
|
impl ::std::str::FromStr for $elem {
|
||||||
type Err = ::error::Error;
|
type Err = crate::error::Error;
|
||||||
fn from_str(s: &str) -> Result<$elem, ::error::Error> {
|
fn from_str(s: &str) -> Result<$elem, crate::error::Error> {
|
||||||
Ok(match s {
|
Ok(match s {
|
||||||
$($b => $elem::$a),+,
|
$($b => $elem::$a),+,
|
||||||
_ => return Err(::error::Error::ParseError(concat!("Unknown value for '", $name, "' attribute."))),
|
_ => return Err(crate::error::Error::ParseError(concat!("Unknown value for '", $name, "' attribute."))),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -78,11 +78,11 @@ macro_rules! generate_attribute {
|
||||||
),+
|
),+
|
||||||
}
|
}
|
||||||
impl ::std::str::FromStr for $elem {
|
impl ::std::str::FromStr for $elem {
|
||||||
type Err = ::error::Error;
|
type Err = crate::error::Error;
|
||||||
fn from_str(s: &str) -> Result<$elem, ::error::Error> {
|
fn from_str(s: &str) -> Result<$elem, crate::error::Error> {
|
||||||
Ok(match s {
|
Ok(match s {
|
||||||
$($b => $elem::$a),+,
|
$($b => $elem::$a),+,
|
||||||
_ => return Err(::error::Error::ParseError(concat!("Unknown value for '", $name, "' attribute."))),
|
_ => return Err(crate::error::Error::ParseError(concat!("Unknown value for '", $name, "' attribute."))),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -111,12 +111,12 @@ macro_rules! generate_attribute {
|
||||||
False,
|
False,
|
||||||
}
|
}
|
||||||
impl ::std::str::FromStr for $elem {
|
impl ::std::str::FromStr for $elem {
|
||||||
type Err = ::error::Error;
|
type Err = crate::error::Error;
|
||||||
fn from_str(s: &str) -> Result<Self, ::error::Error> {
|
fn from_str(s: &str) -> Result<Self, crate::error::Error> {
|
||||||
Ok(match s {
|
Ok(match s {
|
||||||
"true" | "1" => $elem::True,
|
"true" | "1" => $elem::True,
|
||||||
"false" | "0" => $elem::False,
|
"false" | "0" => $elem::False,
|
||||||
_ => return Err(::error::Error::ParseError(concat!("Unknown value for '", $name, "' attribute."))),
|
_ => return Err(crate::error::Error::ParseError(concat!("Unknown value for '", $name, "' attribute."))),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -150,14 +150,14 @@ macro_rules! generate_element_enum {
|
||||||
),+
|
),+
|
||||||
}
|
}
|
||||||
impl ::try_from::TryFrom<::minidom::Element> for $elem {
|
impl ::try_from::TryFrom<::minidom::Element> for $elem {
|
||||||
type Err = ::error::Error;
|
type Err = crate::error::Error;
|
||||||
fn try_from(elem: ::minidom::Element) -> Result<$elem, ::error::Error> {
|
fn try_from(elem: ::minidom::Element) -> Result<$elem, crate::error::Error> {
|
||||||
check_ns_only!(elem, $name, $ns);
|
check_ns_only!(elem, $name, $ns);
|
||||||
check_no_children!(elem, $name);
|
check_no_children!(elem, $name);
|
||||||
check_no_attributes!(elem, $name);
|
check_no_attributes!(elem, $name);
|
||||||
Ok(match elem.name() {
|
Ok(match elem.name() {
|
||||||
$($enum_name => $elem::$enum,)+
|
$($enum_name => $elem::$enum,)+
|
||||||
_ => return Err(::error::Error::ParseError(concat!("This is not a ", $name, " element."))),
|
_ => return Err(crate::error::Error::ParseError(concat!("This is not a ", $name, " element."))),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -165,7 +165,7 @@ macro_rules! generate_element_enum {
|
||||||
fn from(elem: $elem) -> ::minidom::Element {
|
fn from(elem: $elem) -> ::minidom::Element {
|
||||||
::minidom::Element::builder(match elem {
|
::minidom::Element::builder(match elem {
|
||||||
$($elem::$enum => $enum_name,)+
|
$($elem::$enum => $enum_name,)+
|
||||||
}).ns(::ns::$ns)
|
}).ns(crate::ns::$ns)
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -186,21 +186,21 @@ macro_rules! generate_attribute_enum {
|
||||||
),+
|
),+
|
||||||
}
|
}
|
||||||
impl ::try_from::TryFrom<::minidom::Element> for $elem {
|
impl ::try_from::TryFrom<::minidom::Element> for $elem {
|
||||||
type Err = ::error::Error;
|
type Err = crate::error::Error;
|
||||||
fn try_from(elem: ::minidom::Element) -> Result<$elem, ::error::Error> {
|
fn try_from(elem: ::minidom::Element) -> Result<$elem, crate::error::Error> {
|
||||||
check_ns_only!(elem, $name, $ns);
|
check_ns_only!(elem, $name, $ns);
|
||||||
check_no_children!(elem, $name);
|
check_no_children!(elem, $name);
|
||||||
check_no_unknown_attributes!(elem, $name, [$attr]);
|
check_no_unknown_attributes!(elem, $name, [$attr]);
|
||||||
Ok(match get_attr!(elem, $attr, required) {
|
Ok(match get_attr!(elem, $attr, required) {
|
||||||
$($enum_name => $elem::$enum,)+
|
$($enum_name => $elem::$enum,)+
|
||||||
_ => return Err(::error::Error::ParseError(concat!("Invalid ", $name, " ", $attr, " value."))),
|
_ => return Err(crate::error::Error::ParseError(concat!("Invalid ", $name, " ", $attr, " value."))),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<$elem> for ::minidom::Element {
|
impl From<$elem> for ::minidom::Element {
|
||||||
fn from(elem: $elem) -> ::minidom::Element {
|
fn from(elem: $elem) -> ::minidom::Element {
|
||||||
::minidom::Element::builder($name)
|
::minidom::Element::builder($name)
|
||||||
.ns(::ns::$ns)
|
.ns(crate::ns::$ns)
|
||||||
.attr($attr, match elem {
|
.attr($attr, match elem {
|
||||||
$($elem::$enum => $enum_name,)+
|
$($elem::$enum => $enum_name,)+
|
||||||
})
|
})
|
||||||
|
|
@ -215,16 +215,16 @@ macro_rules! check_self {
|
||||||
check_self!($elem, $name, $ns, $name);
|
check_self!($elem, $name, $ns, $name);
|
||||||
);
|
);
|
||||||
($elem:ident, $name:tt, $ns:ident, $pretty_name:tt) => (
|
($elem:ident, $name:tt, $ns:ident, $pretty_name:tt) => (
|
||||||
if !$elem.is($name, ::ns::$ns) {
|
if !$elem.is($name, crate::ns::$ns) {
|
||||||
return Err(::error::Error::ParseError(concat!("This is not a ", $pretty_name, " element.")));
|
return Err(crate::error::Error::ParseError(concat!("This is not a ", $pretty_name, " element.")));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! check_ns_only {
|
macro_rules! check_ns_only {
|
||||||
($elem:ident, $name:tt, $ns:ident) => (
|
($elem:ident, $name:tt, $ns:ident) => (
|
||||||
if !$elem.has_ns(::ns::$ns) {
|
if !$elem.has_ns(crate::ns::$ns) {
|
||||||
return Err(::error::Error::ParseError(concat!("This is not a ", $name, " element.")));
|
return Err(crate::error::Error::ParseError(concat!("This is not a ", $name, " element.")));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -232,7 +232,7 @@ macro_rules! check_ns_only {
|
||||||
macro_rules! check_no_children {
|
macro_rules! check_no_children {
|
||||||
($elem:ident, $name:tt) => (
|
($elem:ident, $name:tt) => (
|
||||||
for _ in $elem.children() {
|
for _ in $elem.children() {
|
||||||
return Err(::error::Error::ParseError(concat!("Unknown child in ", $name, " element.")));
|
return Err(crate::error::Error::ParseError(concat!("Unknown child in ", $name, " element.")));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -240,7 +240,7 @@ macro_rules! check_no_children {
|
||||||
macro_rules! check_no_attributes {
|
macro_rules! check_no_attributes {
|
||||||
($elem:ident, $name:tt) => (
|
($elem:ident, $name:tt) => (
|
||||||
for _ in $elem.attrs() {
|
for _ in $elem.attrs() {
|
||||||
return Err(::error::Error::ParseError(concat!("Unknown attribute in ", $name, " element.")));
|
return Err(crate::error::Error::ParseError(concat!("Unknown attribute in ", $name, " element.")));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -253,7 +253,7 @@ macro_rules! check_no_unknown_attributes {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
)*
|
)*
|
||||||
return Err(::error::Error::ParseError(concat!("Unknown attribute in ", $name, " element.")));
|
return Err(crate::error::Error::ParseError(concat!("Unknown attribute in ", $name, " element.")));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -265,9 +265,9 @@ macro_rules! generate_empty_element {
|
||||||
pub struct $elem;
|
pub struct $elem;
|
||||||
|
|
||||||
impl ::try_from::TryFrom<::minidom::Element> for $elem {
|
impl ::try_from::TryFrom<::minidom::Element> for $elem {
|
||||||
type Err = ::error::Error;
|
type Err = crate::error::Error;
|
||||||
|
|
||||||
fn try_from(elem: ::minidom::Element) -> Result<$elem, ::error::Error> {
|
fn try_from(elem: ::minidom::Element) -> Result<$elem, crate::error::Error> {
|
||||||
check_self!(elem, $name, $ns);
|
check_self!(elem, $name, $ns);
|
||||||
check_no_children!(elem, $name);
|
check_no_children!(elem, $name);
|
||||||
check_no_attributes!(elem, $name);
|
check_no_attributes!(elem, $name);
|
||||||
|
|
@ -278,7 +278,7 @@ macro_rules! generate_empty_element {
|
||||||
impl From<$elem> for ::minidom::Element {
|
impl From<$elem> for ::minidom::Element {
|
||||||
fn from(_: $elem) -> ::minidom::Element {
|
fn from(_: $elem) -> ::minidom::Element {
|
||||||
::minidom::Element::builder($name)
|
::minidom::Element::builder($name)
|
||||||
.ns(::ns::$ns)
|
.ns(crate::ns::$ns)
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -291,8 +291,8 @@ macro_rules! generate_id {
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct $elem(pub String);
|
pub struct $elem(pub String);
|
||||||
impl ::std::str::FromStr for $elem {
|
impl ::std::str::FromStr for $elem {
|
||||||
type Err = ::error::Error;
|
type Err = crate::error::Error;
|
||||||
fn from_str(s: &str) -> Result<$elem, ::error::Error> {
|
fn from_str(s: &str) -> Result<$elem, crate::error::Error> {
|
||||||
// TODO: add a way to parse that differently when needed.
|
// TODO: add a way to parse that differently when needed.
|
||||||
Ok($elem(String::from(s)))
|
Ok($elem(String::from(s)))
|
||||||
}
|
}
|
||||||
|
|
@ -311,15 +311,15 @@ macro_rules! generate_elem_id {
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct $elem(pub String);
|
pub struct $elem(pub String);
|
||||||
impl ::std::str::FromStr for $elem {
|
impl ::std::str::FromStr for $elem {
|
||||||
type Err = ::error::Error;
|
type Err = crate::error::Error;
|
||||||
fn from_str(s: &str) -> Result<$elem, ::error::Error> {
|
fn from_str(s: &str) -> Result<$elem, crate::error::Error> {
|
||||||
// TODO: add a way to parse that differently when needed.
|
// TODO: add a way to parse that differently when needed.
|
||||||
Ok($elem(String::from(s)))
|
Ok($elem(String::from(s)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl ::try_from::TryFrom<::minidom::Element> for $elem {
|
impl ::try_from::TryFrom<::minidom::Element> for $elem {
|
||||||
type Err = ::error::Error;
|
type Err = crate::error::Error;
|
||||||
fn try_from(elem: ::minidom::Element) -> Result<$elem, ::error::Error> {
|
fn try_from(elem: ::minidom::Element) -> Result<$elem, crate::error::Error> {
|
||||||
check_self!(elem, $name, $ns);
|
check_self!(elem, $name, $ns);
|
||||||
check_no_children!(elem, $name);
|
check_no_children!(elem, $name);
|
||||||
check_no_attributes!(elem, $name);
|
check_no_attributes!(elem, $name);
|
||||||
|
|
@ -330,7 +330,7 @@ macro_rules! generate_elem_id {
|
||||||
impl From<$elem> for ::minidom::Element {
|
impl From<$elem> for ::minidom::Element {
|
||||||
fn from(elem: $elem) -> ::minidom::Element {
|
fn from(elem: $elem) -> ::minidom::Element {
|
||||||
::minidom::Element::builder($name)
|
::minidom::Element::builder($name)
|
||||||
.ns(::ns::$ns)
|
.ns(crate::ns::$ns)
|
||||||
.append(elem.0)
|
.append(elem.0)
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
@ -380,13 +380,13 @@ macro_rules! do_parse_elem {
|
||||||
);
|
);
|
||||||
($temp:ident: Option = $constructor:ident => $elem:ident, $name:tt, $parent_name:tt) => (
|
($temp:ident: Option = $constructor:ident => $elem:ident, $name:tt, $parent_name:tt) => (
|
||||||
if $temp.is_some() {
|
if $temp.is_some() {
|
||||||
return Err(::error::Error::ParseError(concat!("Element ", $parent_name, " must not have more than one ", $name, " child.")));
|
return Err(crate::error::Error::ParseError(concat!("Element ", $parent_name, " must not have more than one ", $name, " child.")));
|
||||||
}
|
}
|
||||||
$temp = Some(do_parse!($elem, $constructor));
|
$temp = Some(do_parse!($elem, $constructor));
|
||||||
);
|
);
|
||||||
($temp:ident: Required = $constructor:ident => $elem:ident, $name:tt, $parent_name:tt) => (
|
($temp:ident: Required = $constructor:ident => $elem:ident, $name:tt, $parent_name:tt) => (
|
||||||
if $temp.is_some() {
|
if $temp.is_some() {
|
||||||
return Err(::error::Error::ParseError(concat!("Element ", $parent_name, " must not have more than one ", $name, " child.")));
|
return Err(crate::error::Error::ParseError(concat!("Element ", $parent_name, " must not have more than one ", $name, " child.")));
|
||||||
}
|
}
|
||||||
$temp = Some(do_parse!($elem, $constructor));
|
$temp = Some(do_parse!($elem, $constructor));
|
||||||
);
|
);
|
||||||
|
|
@ -400,21 +400,21 @@ macro_rules! finish_parse_elem {
|
||||||
$temp
|
$temp
|
||||||
);
|
);
|
||||||
($temp:ident: Required = $name:tt, $parent_name:tt) => (
|
($temp:ident: Required = $name:tt, $parent_name:tt) => (
|
||||||
$temp.ok_or(::error::Error::ParseError(concat!("Missing child ", $name, " in ", $parent_name, " element.")))?
|
$temp.ok_or(crate::error::Error::ParseError(concat!("Missing child ", $name, " in ", $parent_name, " element.")))?
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! generate_serialiser {
|
macro_rules! generate_serialiser {
|
||||||
($parent:ident, $elem:ident, Required, String, ($name:tt, $ns:ident)) => (
|
($parent:ident, $elem:ident, Required, String, ($name:tt, $ns:ident)) => (
|
||||||
::minidom::Element::builder($name)
|
::minidom::Element::builder($name)
|
||||||
.ns(::ns::$ns)
|
.ns(crate::ns::$ns)
|
||||||
.append($parent.$elem)
|
.append($parent.$elem)
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
($parent:ident, $elem:ident, Option, String, ($name:tt, $ns:ident)) => (
|
($parent:ident, $elem:ident, Option, String, ($name:tt, $ns:ident)) => (
|
||||||
$parent.$elem.map(|elem|
|
$parent.$elem.map(|elem|
|
||||||
::minidom::Element::builder($name)
|
::minidom::Element::builder($name)
|
||||||
.ns(::ns::$ns)
|
.ns(crate::ns::$ns)
|
||||||
.append(elem)
|
.append(elem)
|
||||||
.build())
|
.build())
|
||||||
);
|
);
|
||||||
|
|
@ -461,9 +461,9 @@ macro_rules! generate_element {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::try_from::TryFrom<::minidom::Element> for $elem {
|
impl ::try_from::TryFrom<::minidom::Element> for $elem {
|
||||||
type Err = ::error::Error;
|
type Err = crate::error::Error;
|
||||||
|
|
||||||
fn try_from(elem: ::minidom::Element) -> Result<$elem, ::error::Error> {
|
fn try_from(elem: ::minidom::Element) -> Result<$elem, crate::error::Error> {
|
||||||
check_self!(elem, $name, $ns);
|
check_self!(elem, $name, $ns);
|
||||||
check_no_unknown_attributes!(elem, $name, [$($attr_name),*]);
|
check_no_unknown_attributes!(elem, $name, [$($attr_name),*]);
|
||||||
$(
|
$(
|
||||||
|
|
@ -471,12 +471,12 @@ macro_rules! generate_element {
|
||||||
)*
|
)*
|
||||||
for _child in elem.children() {
|
for _child in elem.children() {
|
||||||
$(
|
$(
|
||||||
if _child.is($child_name, ::ns::$child_ns) {
|
if _child.is($child_name, crate::ns::$child_ns) {
|
||||||
do_parse_elem!($child_ident: $coucou = $child_constructor => _child, $child_name, $name);
|
do_parse_elem!($child_ident: $coucou = $child_constructor => _child, $child_name, $name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
)*
|
)*
|
||||||
return Err(::error::Error::ParseError(concat!("Unknown child in ", $name, " element.")));
|
return Err(crate::error::Error::ParseError(concat!("Unknown child in ", $name, " element.")));
|
||||||
}
|
}
|
||||||
Ok($elem {
|
Ok($elem {
|
||||||
$(
|
$(
|
||||||
|
|
@ -495,7 +495,7 @@ macro_rules! generate_element {
|
||||||
impl From<$elem> for ::minidom::Element {
|
impl From<$elem> for ::minidom::Element {
|
||||||
fn from(elem: $elem) -> ::minidom::Element {
|
fn from(elem: $elem) -> ::minidom::Element {
|
||||||
::minidom::Element::builder($name)
|
::minidom::Element::builder($name)
|
||||||
.ns(::ns::$ns)
|
.ns(crate::ns::$ns)
|
||||||
$(
|
$(
|
||||||
.attr($attr_name, elem.$attr)
|
.attr($attr_name, elem.$attr)
|
||||||
)*
|
)*
|
||||||
|
|
|
||||||
16
src/mam.rs
16
src/mam.rs
|
|
@ -9,16 +9,16 @@ use try_from::TryFrom;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use jid::Jid;
|
use jid::Jid;
|
||||||
|
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
|
|
||||||
use message::MessagePayload;
|
use crate::message::MessagePayload;
|
||||||
use iq::{IqGetPayload, IqSetPayload, IqResultPayload};
|
use crate::iq::{IqGetPayload, IqSetPayload, IqResultPayload};
|
||||||
use data_forms::DataForm;
|
use crate::data_forms::DataForm;
|
||||||
use rsm::{SetQuery, SetResult};
|
use crate::rsm::{SetQuery, SetResult};
|
||||||
use forwarding::Forwarded;
|
use crate::forwarding::Forwarded;
|
||||||
use pubsub::NodeName;
|
use crate::pubsub::NodeName;
|
||||||
|
|
||||||
use ns;
|
use crate::ns;
|
||||||
|
|
||||||
generate_id!(
|
generate_id!(
|
||||||
/// An identifier matching a result message to the query requesting it.
|
/// An identifier matching a result message to the query requesting it.
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
// 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/.
|
||||||
|
|
||||||
use helpers::TrimmedPlainText;
|
use crate::helpers::TrimmedPlainText;
|
||||||
|
|
||||||
generate_element!(
|
generate_element!(
|
||||||
/// Represents an URI used in a media element.
|
/// Represents an URI used in a media element.
|
||||||
|
|
@ -47,8 +47,8 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use try_from::TryFrom;
|
use try_from::TryFrom;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
use data_forms::DataForm;
|
use crate::data_forms::DataForm;
|
||||||
use std::error::Error as StdError;
|
use std::error::Error as StdError;
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,9 @@ use minidom::Element;
|
||||||
|
|
||||||
use jid::Jid;
|
use jid::Jid;
|
||||||
|
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
|
|
||||||
use ns;
|
use crate::ns;
|
||||||
|
|
||||||
/// Should be implemented on every known payload of a `<message/>`.
|
/// Should be implemented on every known payload of a `<message/>`.
|
||||||
pub trait MessagePayload: TryFrom<Element> + Into<Element> {}
|
pub trait MessagePayload: TryFrom<Element> + Into<Element> {}
|
||||||
|
|
@ -232,7 +232,7 @@ impl From<Message> for Element {
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use compare_elements::NamespaceAwareCompare;
|
use crate::compare_elements::NamespaceAwareCompare;
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
// 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/.
|
||||||
|
|
||||||
use message::MessagePayload;
|
use crate::message::MessagePayload;
|
||||||
|
|
||||||
generate_element!(
|
generate_element!(
|
||||||
/// Defines that the message containing this payload should replace a
|
/// Defines that the message containing this payload should replace a
|
||||||
|
|
@ -23,7 +23,7 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use try_from::TryFrom;
|
use try_from::TryFrom;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
// 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/.
|
||||||
|
|
||||||
use presence::PresencePayload;
|
use crate::presence::PresencePayload;
|
||||||
use date::DateTime;
|
use crate::date::DateTime;
|
||||||
|
|
||||||
generate_element!(
|
generate_element!(
|
||||||
/// Represents the query for messages before our join.
|
/// Represents the query for messages before our join.
|
||||||
|
|
@ -104,9 +104,9 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use try_from::TryFrom;
|
use try_from::TryFrom;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use compare_elements::NamespaceAwareCompare;
|
use crate::compare_elements::NamespaceAwareCompare;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_muc_simple() {
|
fn test_muc_simple() {
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,9 @@ use minidom::Element;
|
||||||
|
|
||||||
use jid::Jid;
|
use jid::Jid;
|
||||||
|
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
|
|
||||||
use ns;
|
use crate::ns;
|
||||||
|
|
||||||
generate_attribute_enum!(
|
generate_attribute_enum!(
|
||||||
/// Lists all of the possible status codes used in MUC presences.
|
/// Lists all of the possible status codes used in MUC presences.
|
||||||
|
|
@ -238,7 +238,7 @@ generate_element!(
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::error::Error as StdError;
|
use std::error::Error as StdError;
|
||||||
use compare_elements::NamespaceAwareCompare;
|
use crate::compare_elements::NamespaceAwareCompare;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_simple() {
|
fn test_simple() {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use try_from::TryFrom;
|
use try_from::TryFrom;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
// 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/.
|
||||||
|
|
||||||
use iq::IqGetPayload;
|
use crate::iq::IqGetPayload;
|
||||||
|
|
||||||
generate_empty_element!(
|
generate_empty_element!(
|
||||||
/// Represents a ping to the recipient, which must be answered with an
|
/// Represents a ping to the recipient, which must be answered with an
|
||||||
|
|
@ -20,7 +20,7 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use try_from::TryFrom;
|
use try_from::TryFrom;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_size() {
|
fn test_size() {
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@ use minidom::{Element, IntoElements, IntoAttributeValue, ElementEmitter};
|
||||||
|
|
||||||
use jid::Jid;
|
use jid::Jid;
|
||||||
|
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
|
|
||||||
use ns;
|
use crate::ns;
|
||||||
|
|
||||||
/// Should be implemented on every known payload of a `<presence/>`.
|
/// Should be implemented on every known payload of a `<presence/>`.
|
||||||
pub trait PresencePayload: TryFrom<Element> + Into<Element> {}
|
pub trait PresencePayload: TryFrom<Element> + Into<Element> {}
|
||||||
|
|
@ -331,7 +331,7 @@ impl From<Presence> for Element {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use compare_elements::NamespaceAwareCompare;
|
use crate::compare_elements::NamespaceAwareCompare;
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -8,15 +8,15 @@ use try_from::TryFrom;
|
||||||
|
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use jid::Jid;
|
use jid::Jid;
|
||||||
use date::DateTime;
|
use crate::date::DateTime;
|
||||||
|
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
|
|
||||||
use ns;
|
use crate::ns;
|
||||||
|
|
||||||
use data_forms::DataForm;
|
use crate::data_forms::DataForm;
|
||||||
|
|
||||||
use pubsub::{NodeName, ItemId, Subscription, SubscriptionId};
|
use crate::pubsub::{NodeName, ItemId, Subscription, SubscriptionId};
|
||||||
|
|
||||||
/// One PubSub item from a node.
|
/// One PubSub item from a node.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|
@ -288,7 +288,7 @@ impl From<PubSubEvent> for Element {
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use compare_elements::NamespaceAwareCompare;
|
use crate::compare_elements::NamespaceAwareCompare;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn missing_items() {
|
fn missing_items() {
|
||||||
|
|
|
||||||
|
|
@ -9,14 +9,14 @@ use try_from::TryFrom;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use jid::Jid;
|
use jid::Jid;
|
||||||
|
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
|
|
||||||
use ns;
|
use crate::ns;
|
||||||
|
|
||||||
use iq::{IqGetPayload, IqSetPayload, IqResultPayload};
|
use crate::iq::{IqGetPayload, IqSetPayload, IqResultPayload};
|
||||||
use data_forms::DataForm;
|
use crate::data_forms::DataForm;
|
||||||
|
|
||||||
use pubsub::{NodeName, ItemId, Subscription, SubscriptionId};
|
use crate::pubsub::{NodeName, ItemId, Subscription, SubscriptionId};
|
||||||
|
|
||||||
// TODO: a better solution would be to split this into a query and a result elements, like for
|
// TODO: a better solution would be to split this into a query and a result elements, like for
|
||||||
// XEP-0030.
|
// XEP-0030.
|
||||||
|
|
@ -497,7 +497,7 @@ impl From<PubSub> for Element {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use compare_elements::NamespaceAwareCompare;
|
use crate::compare_elements::NamespaceAwareCompare;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn create() {
|
fn create() {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
// 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/.
|
||||||
|
|
||||||
use message::MessagePayload;
|
use crate::message::MessagePayload;
|
||||||
|
|
||||||
generate_empty_element!(
|
generate_empty_element!(
|
||||||
/// Requests that this message is acked by the final recipient once
|
/// Requests that this message is acked by the final recipient once
|
||||||
|
|
@ -31,7 +31,7 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use try_from::TryFrom;
|
use try_from::TryFrom;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use ns;
|
use crate::ns;
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
use jid::Jid;
|
use jid::Jid;
|
||||||
use iq::{IqGetPayload, IqSetPayload, IqResultPayload};
|
use crate::iq::{IqGetPayload, IqSetPayload, IqResultPayload};
|
||||||
|
|
||||||
generate_elem_id!(
|
generate_elem_id!(
|
||||||
/// Represents a group a contact is part of.
|
/// Represents a group a contact is part of.
|
||||||
|
|
@ -81,9 +81,9 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use try_from::TryFrom;
|
use try_from::TryFrom;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use compare_elements::NamespaceAwareCompare;
|
use crate::compare_elements::NamespaceAwareCompare;
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@ use try_from::TryFrom;
|
||||||
|
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
|
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
|
|
||||||
use ns;
|
use crate::ns;
|
||||||
|
|
||||||
/// Requests paging through a potentially big set of items (represented by an
|
/// Requests paging through a potentially big set of items (represented by an
|
||||||
/// UID).
|
/// UID).
|
||||||
|
|
@ -156,7 +156,7 @@ impl From<SetResult> for Element {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use compare_elements::NamespaceAwareCompare;
|
use crate::compare_elements::NamespaceAwareCompare;
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,10 @@ use std::collections::BTreeMap;
|
||||||
|
|
||||||
use try_from::TryFrom;
|
use try_from::TryFrom;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
use ns;
|
use crate::ns;
|
||||||
|
|
||||||
use helpers::Base64;
|
use crate::helpers::Base64;
|
||||||
|
|
||||||
generate_attribute!(
|
generate_attribute!(
|
||||||
/// The list of available SASL mechanisms.
|
/// The list of available SASL mechanisms.
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
// 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/.
|
||||||
|
|
||||||
use stanza_error::DefinedCondition;
|
use crate::stanza_error::DefinedCondition;
|
||||||
|
|
||||||
generate_element!(
|
generate_element!(
|
||||||
/// Acknowledgement of the currently received stanzas.
|
/// Acknowledgement of the currently received stanzas.
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,11 @@ use std::collections::BTreeMap;
|
||||||
|
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
|
|
||||||
use message::MessagePayload;
|
use crate::message::MessagePayload;
|
||||||
use presence::PresencePayload;
|
use crate::presence::PresencePayload;
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
use jid::Jid;
|
use jid::Jid;
|
||||||
use ns;
|
use crate::ns;
|
||||||
|
|
||||||
generate_attribute!(
|
generate_attribute!(
|
||||||
/// The type of the error.
|
/// The type of the error.
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
// 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/.
|
||||||
|
|
||||||
use message::MessagePayload;
|
use crate::message::MessagePayload;
|
||||||
use jid::Jid;
|
use jid::Jid;
|
||||||
|
|
||||||
generate_element!(
|
generate_element!(
|
||||||
|
|
@ -39,7 +39,7 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use try_from::TryFrom;
|
use try_from::TryFrom;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
// 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/.
|
||||||
|
|
||||||
use iq::{IqGetPayload, IqResultPayload};
|
use crate::iq::{IqGetPayload, IqResultPayload};
|
||||||
|
|
||||||
generate_empty_element!(
|
generate_empty_element!(
|
||||||
/// Represents a query for the software version a remote entity is using.
|
/// Represents a query for the software version a remote entity is using.
|
||||||
|
|
@ -41,7 +41,7 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use try_from::TryFrom;
|
use try_from::TryFrom;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use compare_elements::NamespaceAwareCompare;
|
use crate::compare_elements::NamespaceAwareCompare;
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue