Port everything over to AsXml
This commit is contained in:
parent
4910b01244
commit
ccf38cdf9b
64 changed files with 848 additions and 371 deletions
|
|
@ -3,13 +3,13 @@
|
|||
// 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 xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use crate::message::MessagePayload;
|
||||
use crate::ns;
|
||||
|
||||
/// Requests the attention of the recipient.
|
||||
#[derive(FromXml, IntoXml, Debug, Clone, PartialEq)]
|
||||
#[derive(FromXml, AsXml, Debug, Clone, PartialEq)]
|
||||
#[xml(namespace = ns::ATTENTION, name = "attention")]
|
||||
pub struct Attention;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
// 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 xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use crate::hashes::Sha1HexAttribute;
|
||||
use crate::ns;
|
||||
|
|
@ -23,7 +23,7 @@ generate_element!(
|
|||
impl PubSubPayload for Metadata {}
|
||||
|
||||
/// Communicates avatar metadata.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::AVATAR_METADATA, name = "info")]
|
||||
pub struct Info {
|
||||
/// The size of the image data in bytes.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
// 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 xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use crate::iq::{IqGetPayload, IqResultPayload, IqSetPayload};
|
||||
use crate::ns;
|
||||
|
|
@ -14,7 +14,7 @@ use xso::error::FromElementError;
|
|||
|
||||
/// The element requesting the blocklist, the result iq will contain a
|
||||
/// [BlocklistResult].
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::BLOCKING, name = "blocklist")]
|
||||
pub struct BlocklistRequest;
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ generate_blocking_element!(
|
|||
impl IqSetPayload for Unblock {}
|
||||
|
||||
/// The application-specific error condition when a message is blocked.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::BLOCKING_ERRORS, name = "blocked")]
|
||||
pub struct Blocked;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,12 +4,14 @@
|
|||
// 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 xso::{error::Error, text::Base64, FromXml, FromXmlText, IntoXml, IntoXmlText};
|
||||
use std::borrow::Cow;
|
||||
use std::str::FromStr;
|
||||
|
||||
use xso::{error::Error, text::Base64, AsXml, AsXmlText, FromXml, FromXmlText};
|
||||
|
||||
use crate::hashes::{Algo, Hash};
|
||||
use crate::ns;
|
||||
use minidom::IntoAttributeValue;
|
||||
use std::str::FromStr;
|
||||
|
||||
/// A Content-ID, as defined in RFC2111.
|
||||
///
|
||||
|
|
@ -56,14 +58,18 @@ impl FromXmlText for ContentId {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoXmlText for ContentId {
|
||||
fn into_xml_text(self) -> Result<String, Error> {
|
||||
impl AsXmlText for ContentId {
|
||||
fn as_xml_text(&self) -> Result<Cow<'_, str>, Error> {
|
||||
let algo = match self.hash.algo {
|
||||
Algo::Sha_1 => "sha1",
|
||||
Algo::Sha_256 => "sha256",
|
||||
_ => unimplemented!(),
|
||||
};
|
||||
Ok(format!("{}+{}@bob.xmpp.org", algo, self.hash.to_hex()))
|
||||
Ok(Cow::Owned(format!(
|
||||
"{}+{}@bob.xmpp.org",
|
||||
algo,
|
||||
self.hash.to_hex()
|
||||
)))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -79,7 +85,7 @@ impl IntoAttributeValue for ContentId {
|
|||
}
|
||||
|
||||
/// Request for an uncached cid file.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::BOB, name = "data")]
|
||||
pub struct Data {
|
||||
/// The cid in question.
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
//!
|
||||
//! The [`Conference`][crate::bookmarks::Conference] struct used in [`private::Query`][`crate::private::Query`] is the one from this module. Only the querying mechanism changes from a legacy PubSub implementation here, to a legacy Private XML Query implementation in that other module. The [`Conference`][crate::bookmarks2::Conference] element from the [`bookmarks2`][crate::bookmarks2] module is a different structure, but conversion is possible from [`bookmarks::Conference`][crate::bookmarks::Conference] to [`bookmarks2::Conference`][crate::bookmarks2::Conference] via the [`Conference::into_bookmarks2`][crate::bookmarks::Conference::into_bookmarks2] method.
|
||||
|
||||
use xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use jid::BareJid;
|
||||
|
||||
|
|
@ -63,7 +63,7 @@ impl Conference {
|
|||
}
|
||||
|
||||
/// An URL bookmark.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::BOOKMARKS, name = "url")]
|
||||
pub struct Url {
|
||||
/// A user-defined name for this URL.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
// 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 xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use crate::forwarding::Forwarded;
|
||||
use crate::iq::IqSetPayload;
|
||||
|
|
@ -12,14 +12,14 @@ use crate::message::MessagePayload;
|
|||
use crate::ns;
|
||||
|
||||
/// Enable carbons for this session.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::CARBONS, name = "enable")]
|
||||
pub struct Enable;
|
||||
|
||||
impl IqSetPayload for Enable {}
|
||||
|
||||
/// Disable a previously-enabled carbons.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::CARBONS, name = "disable")]
|
||||
pub struct Disable;
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ impl IqSetPayload for Disable {}
|
|||
|
||||
/// Request the enclosing message to not be copied to other carbons-enabled
|
||||
/// resources of the user.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::CARBONS, name = "private")]
|
||||
pub struct Private;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
// 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 xso::{text::Base64, FromXml, IntoXml};
|
||||
use xso::{text::Base64, AsXml, FromXml};
|
||||
|
||||
use crate::iq::{IqGetPayload, IqResultPayload, IqSetPayload};
|
||||
use crate::ns;
|
||||
|
|
@ -17,7 +17,7 @@ generate_elem_id!(
|
|||
);
|
||||
|
||||
/// An X.509 certificate.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::SASL_CERT, name = "x509cert")]
|
||||
pub struct Cert {
|
||||
/// The BER X.509 data.
|
||||
|
|
@ -43,7 +43,7 @@ generate_element!(
|
|||
impl IqSetPayload for Append {}
|
||||
|
||||
/// Client requests the current list of X.509 certificates.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::SASL_CERT, name = "items")]
|
||||
pub struct ListCertsQuery;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,22 +4,22 @@
|
|||
// 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 xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use crate::ns;
|
||||
|
||||
/// Stream:feature sent by the server to advertise it supports CSI.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::CSI, name = "csi")]
|
||||
pub struct Feature;
|
||||
|
||||
/// Client indicates it is inactive.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::CSI, name = "inactive")]
|
||||
pub struct Inactive;
|
||||
|
||||
/// Client indicates it is active again.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::CSI, name = "active")]
|
||||
pub struct Active;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use std::fmt::{Display, Formatter};
|
|||
use std::str::FromStr;
|
||||
|
||||
use minidom::{Element, IntoAttributeValue};
|
||||
use xso::{error::FromElementError, FromXml, IntoXml};
|
||||
use xso::{error::FromElementError, AsXml, FromXml};
|
||||
|
||||
use crate::ns::{self, XDATA_VALIDATE};
|
||||
use crate::Error;
|
||||
|
|
@ -67,7 +67,7 @@ pub enum Method {
|
|||
}
|
||||
|
||||
/// Selection Ranges in "list-multi"
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::XDATA_VALIDATE, name = "list-range")]
|
||||
pub struct ListRange {
|
||||
/// The 'min' attribute specifies the minimum allowable number of selected/entered values.
|
||||
|
|
|
|||
|
|
@ -4,9 +4,10 @@
|
|||
// 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 std::borrow::Cow;
|
||||
use std::str::FromStr;
|
||||
|
||||
use xso::{error::Error, FromXmlText, IntoXmlText};
|
||||
use xso::{error::Error, AsXmlText, FromXmlText};
|
||||
|
||||
use chrono::{DateTime as ChronoDateTime, FixedOffset};
|
||||
use minidom::{IntoAttributeValue, Node};
|
||||
|
|
@ -48,9 +49,9 @@ impl FromXmlText for DateTime {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoXmlText for DateTime {
|
||||
fn into_xml_text(self) -> Result<String, Error> {
|
||||
Ok(self.0.to_rfc3339())
|
||||
impl AsXmlText for DateTime {
|
||||
fn as_xml_text(&self) -> Result<Cow<'_, str>, Error> {
|
||||
Ok(Cow::Owned(self.0.to_rfc3339()))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
// 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 xso::{text::EmptyAsNone, FromXml, IntoXml};
|
||||
use xso::{text::EmptyAsNone, AsXml, FromXml};
|
||||
|
||||
use crate::date::DateTime;
|
||||
use crate::message::MessagePayload;
|
||||
|
|
@ -13,7 +13,7 @@ use crate::presence::PresencePayload;
|
|||
use jid::Jid;
|
||||
|
||||
/// Notes when and by whom a message got stored for later delivery.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::DELAY, name = "delay")]
|
||||
pub struct Delay {
|
||||
/// The entity which delayed this message.
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
use xso::{
|
||||
error::{Error, FromElementError},
|
||||
FromXml, IntoXml,
|
||||
AsXml, FromXml,
|
||||
};
|
||||
|
||||
use crate::data_forms::{DataForm, DataFormType};
|
||||
|
|
@ -20,7 +20,7 @@ use jid::Jid;
|
|||
///
|
||||
/// It should only be used in an `<iq type='get'/>`, as it can only represent
|
||||
/// the request, and not a result.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::DISCO_INFO, name = "query")]
|
||||
pub struct DiscoInfoQuery {
|
||||
/// Node on which we are doing the discovery.
|
||||
|
|
@ -31,7 +31,7 @@ pub struct DiscoInfoQuery {
|
|||
impl IqGetPayload for DiscoInfoQuery {}
|
||||
|
||||
/// Structure representing a `<feature xmlns='http://jabber.org/protocol/disco#info'/>` element.
|
||||
#[derive(FromXml, IntoXml, Debug, Clone, PartialEq, Eq, Hash)]
|
||||
#[derive(FromXml, AsXml, Debug, Clone, PartialEq, Eq, Hash)]
|
||||
#[xml(namespace = ns::DISCO_INFO, name = "feature")]
|
||||
pub struct Feature {
|
||||
/// Namespace of the feature we want to represent.
|
||||
|
|
@ -203,7 +203,7 @@ children: [
|
|||
impl IqGetPayload for DiscoItemsQuery {}
|
||||
|
||||
/// Structure representing an `<item xmlns='http://jabber.org/protocol/disco#items'/>` element.
|
||||
#[derive(FromXml, IntoXml, Debug, Clone, PartialEq)]
|
||||
#[derive(FromXml, AsXml, Debug, Clone, PartialEq)]
|
||||
#[xml(namespace = ns::DISCO_ITEMS, name = "item")]
|
||||
pub struct Item {
|
||||
/// JID of the entity pointed by this item.
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@
|
|||
// 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 xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use crate::message::MessagePayload;
|
||||
use crate::ns;
|
||||
|
||||
/// Structure representing an `<encryption xmlns='urn:xmpp:eme:0'/>` element.
|
||||
#[derive(FromXml, IntoXml, Debug, Clone, PartialEq)]
|
||||
#[derive(FromXml, AsXml, Debug, Clone, PartialEq)]
|
||||
#[xml(namespace = ns::EME, name = "encryption")]
|
||||
pub struct ExplicitMessageEncryption {
|
||||
/// Namespace of the encryption scheme used.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
// 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 xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use crate::data_forms::DataForm;
|
||||
use crate::date::DateTime;
|
||||
|
|
@ -101,7 +101,7 @@ generate_element!(
|
|||
impl IqGetPayload for Service {}
|
||||
|
||||
/// Structure representing a `<services xmlns='urn:xmpp:extdisco:2'/>` element.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::EXT_DISCO, name = "services")]
|
||||
pub struct ServicesQuery {
|
||||
/// TODO
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
// 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 xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use crate::date::DateTime;
|
||||
use crate::ns;
|
||||
|
|
@ -14,7 +14,7 @@ generate_elem_id!(
|
|||
Mechanism, "mechanism", FAST
|
||||
);
|
||||
|
||||
// TODO: Replace this with a proper bool once we can derive FromXml and IntoXml on FastQuery.
|
||||
// TODO: Replace this with a proper bool once we can derive FromXml and AsXml on FastQuery.
|
||||
generate_attribute!(
|
||||
/// Whether TLS zero-roundtrip is possible.
|
||||
Tls0Rtt, "tls-0rtt", bool
|
||||
|
|
@ -34,7 +34,7 @@ children: [
|
|||
);
|
||||
|
||||
/// This is the `<fast/>` element the client MUST include within its SASL2 authentication request.
|
||||
#[derive(FromXml, IntoXml, Debug, Clone, PartialEq)]
|
||||
#[derive(FromXml, AsXml, Debug, Clone, PartialEq)]
|
||||
#[xml(namespace = ns::FAST, name = "fast")]
|
||||
pub struct FastResponse {
|
||||
/// Servers MUST reject any authentication requests received via TLS 0-RTT payloads that do not
|
||||
|
|
@ -51,7 +51,7 @@ pub struct FastResponse {
|
|||
}
|
||||
|
||||
/// This is the `<request-token/>` element sent by the client in the SASL2 authenticate step.
|
||||
#[derive(FromXml, IntoXml, Debug, Clone, PartialEq)]
|
||||
#[derive(FromXml, AsXml, Debug, Clone, PartialEq)]
|
||||
#[xml(namespace = ns::FAST, name = "request-token")]
|
||||
pub struct RequestToken {
|
||||
/// This element MUST contain a 'mechanism' attribute, the value of which MUST be one of the
|
||||
|
|
@ -62,7 +62,7 @@ pub struct RequestToken {
|
|||
|
||||
/// This is the `<token/>` element sent by the server on successful SASL2 authentication containing
|
||||
/// a `<request-token/>` element.
|
||||
#[derive(FromXml, IntoXml, Debug, Clone, PartialEq)]
|
||||
#[derive(FromXml, AsXml, Debug, Clone, PartialEq)]
|
||||
#[xml(namespace = ns::FAST, name = "token")]
|
||||
pub struct Token {
|
||||
/// The secret token to be used for subsequent authentications, as generated by the server.
|
||||
|
|
|
|||
|
|
@ -4,14 +4,16 @@
|
|||
// 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 xso::{error::Error, text::Base64, FromXml, FromXmlText, IntoXml, IntoXmlText};
|
||||
|
||||
use base64::{engine::general_purpose::STANDARD as Base64Engine, Engine};
|
||||
use minidom::IntoAttributeValue;
|
||||
use std::borrow::Cow;
|
||||
use std::num::ParseIntError;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::str::FromStr;
|
||||
|
||||
use xso::{error::Error, text::Base64, AsXml, AsXmlText, FromXml, FromXmlText};
|
||||
|
||||
use base64::{engine::general_purpose::STANDARD as Base64Engine, Engine};
|
||||
use minidom::IntoAttributeValue;
|
||||
|
||||
use crate::ns;
|
||||
|
||||
/// List of the algorithms we support, or Unknown.
|
||||
|
|
@ -97,9 +99,9 @@ impl FromXmlText for Algo {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoXmlText for Algo {
|
||||
fn into_xml_text(self) -> Result<String, Error> {
|
||||
Ok(String::from(match self {
|
||||
impl AsXmlText for Algo {
|
||||
fn as_xml_text(&self) -> Result<Cow<'_, str>, Error> {
|
||||
Ok(Cow::Borrowed(match self {
|
||||
Algo::Sha_1 => "sha-1",
|
||||
Algo::Sha_256 => "sha-256",
|
||||
Algo::Sha_512 => "sha-512",
|
||||
|
|
@ -107,7 +109,7 @@ impl IntoXmlText for Algo {
|
|||
Algo::Sha3_512 => "sha3-512",
|
||||
Algo::Blake2b_256 => "blake2b-256",
|
||||
Algo::Blake2b_512 => "blake2b-512",
|
||||
Algo::Unknown(text) => return Ok(text),
|
||||
Algo::Unknown(text) => text.as_str(),
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
|
@ -120,7 +122,7 @@ impl IntoAttributeValue for Algo {
|
|||
|
||||
/// This element represents a hash of some data, defined by the hash
|
||||
/// algorithm used and the computed value.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::HASHES, name = "hash")]
|
||||
pub struct Hash {
|
||||
/// The algorithm used to create this hash.
|
||||
|
|
@ -213,9 +215,9 @@ impl FromXmlText for Sha1HexAttribute {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoXmlText for Sha1HexAttribute {
|
||||
fn into_xml_text(self) -> Result<String, xso::error::Error> {
|
||||
Ok(self.to_hex())
|
||||
impl AsXmlText for Sha1HexAttribute {
|
||||
fn as_xml_text(&self) -> Result<Cow<'_, str>, xso::error::Error> {
|
||||
Ok(Cow::Owned(self.to_hex()))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
use xso::{
|
||||
error::{Error, FromElementError},
|
||||
FromXml, IntoXml,
|
||||
AsXml, FromXml,
|
||||
};
|
||||
|
||||
use crate::iq::{IqGetPayload, IqResultPayload};
|
||||
|
|
@ -14,7 +14,7 @@ use crate::ns;
|
|||
use crate::Element;
|
||||
|
||||
/// Requesting a slot
|
||||
#[derive(FromXml, IntoXml, Debug, Clone, PartialEq)]
|
||||
#[derive(FromXml, AsXml, Debug, Clone, PartialEq)]
|
||||
#[xml(namespace = ns::HTTP_UPLOAD, name = "request")]
|
||||
pub struct SlotRequest {
|
||||
/// The filename to be uploaded.
|
||||
|
|
@ -97,7 +97,7 @@ generate_element!(
|
|||
);
|
||||
|
||||
/// Get URL
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::HTTP_UPLOAD, name = "get")]
|
||||
pub struct Get {
|
||||
/// URL
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
// 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 xso::{text::Base64, FromXml, IntoXml};
|
||||
use xso::{text::Base64, AsXml, FromXml};
|
||||
|
||||
use crate::iq::IqSetPayload;
|
||||
use crate::ns;
|
||||
|
|
@ -44,7 +44,7 @@ attributes: [
|
|||
impl IqSetPayload for Open {}
|
||||
|
||||
/// Exchange a chunk of data in an open stream.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::IBB, name = "data")]
|
||||
pub struct Data {
|
||||
/// Sequence number of this chunk, must wraparound after 65535.
|
||||
|
|
@ -63,7 +63,7 @@ pub struct Data {
|
|||
impl IqSetPayload for Data {}
|
||||
|
||||
/// Close an open stream.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::IBB, name = "close")]
|
||||
pub struct Close {
|
||||
/// The identifier of the stream to be closed.
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@
|
|||
// 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 xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use crate::date::DateTime;
|
||||
use crate::ns;
|
||||
use crate::presence::PresencePayload;
|
||||
|
||||
/// Represents the last time the user interacted with their system.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::IDLE, name = "idle")]
|
||||
pub struct Idle {
|
||||
/// The time at which the user stopped interacting.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
// 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 xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use jid::Jid;
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ use crate::iq::{IqGetPayload, IqResultPayload};
|
|||
use crate::ns;
|
||||
|
||||
/// Request from a client to stringprep/PRECIS a string into a JID.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::JID_PREP, name = "jid")]
|
||||
pub struct JidPrepQuery {
|
||||
/// The potential JID.
|
||||
|
|
@ -30,7 +30,7 @@ impl JidPrepQuery {
|
|||
}
|
||||
|
||||
/// Response from the server with the stringprep’d/PRECIS’d JID.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::JID_PREP, name = "jid")]
|
||||
pub struct JidPrepResponse {
|
||||
/// The JID.
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ use std::collections::BTreeMap;
|
|||
use std::str::FromStr;
|
||||
use xso::{
|
||||
error::{Error, FromElementError},
|
||||
FromXml, IntoXml,
|
||||
AsXml, FromXml,
|
||||
};
|
||||
|
||||
generate_element!(
|
||||
|
|
@ -323,7 +323,7 @@ impl From<Checksum> for Element {
|
|||
}
|
||||
|
||||
/// A notice that the file transfer has been completed.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::JINGLE_FT, name = "received")]
|
||||
pub struct Received {
|
||||
/// The content identifier of this Jingle session.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
// 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 xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use crate::jingle::ContentId;
|
||||
use crate::ns;
|
||||
|
|
@ -21,7 +21,7 @@ generate_attribute!(
|
|||
);
|
||||
|
||||
/// Describes a content that should be grouped with other ones.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::JINGLE_GROUPING, name = "content")]
|
||||
pub struct Content {
|
||||
/// The name of the matching [`Content`](crate::jingle::Content).
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
use std::net::IpAddr;
|
||||
|
||||
use xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use crate::jingle_dtls_srtp::Fingerprint;
|
||||
use crate::ns;
|
||||
|
|
@ -68,7 +68,7 @@ generate_attribute!(
|
|||
);
|
||||
|
||||
/// A candidate for an ICE-UDP session.
|
||||
#[derive(FromXml, IntoXml, Debug, PartialEq, Clone)]
|
||||
#[derive(FromXml, AsXml, Debug, PartialEq, Clone)]
|
||||
#[xml(namespace = ns::JINGLE_ICE_UDP, name = "candidate")]
|
||||
pub struct Candidate {
|
||||
/// A Component ID as defined in ICE-CORE.
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
use std::net::IpAddr;
|
||||
|
||||
use xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use crate::jingle_ice_udp::Type;
|
||||
use crate::ns;
|
||||
|
|
@ -35,7 +35,7 @@ impl Transport {
|
|||
}
|
||||
|
||||
/// A candidate for an ICE-UDP session.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::JINGLE_RAW_UDP, name = "candidate")]
|
||||
pub struct Candidate {
|
||||
/// A Component ID as defined in ICE-CORE.
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@
|
|||
// 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 xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use crate::ns;
|
||||
|
||||
/// Wrapper element for a rtcp-fb.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::JINGLE_RTCP_FB, name = "rtcp-fb")]
|
||||
pub struct RtcpFb {
|
||||
/// Type of this rtcp-fb.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
// 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 xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use crate::jingle_rtcp_fb::RtcpFb;
|
||||
use crate::jingle_rtp_hdrext::RtpHdrext;
|
||||
|
|
@ -13,7 +13,7 @@ use crate::ns;
|
|||
|
||||
/// Specifies the ability to multiplex RTP Data and Control Packets on a single port as
|
||||
/// described in RFC 5761.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::JINGLE_RTP, name = "rtcp-mux")]
|
||||
pub struct RtcpMux;
|
||||
|
||||
|
|
@ -138,7 +138,7 @@ impl PayloadType {
|
|||
}
|
||||
|
||||
/// Parameter related to a payload.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::JINGLE_RTP, name = "parameter")]
|
||||
pub struct Parameter {
|
||||
/// The name of the parameter, from the list at
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
// 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 xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use crate::ns;
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ impl Source {
|
|||
}
|
||||
|
||||
/// Parameter associated with a ssrc.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::JINGLE_SSMA, name = "parameter")]
|
||||
pub struct Parameter {
|
||||
/// The name of the parameter.
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@
|
|||
// 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 xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use crate::ns;
|
||||
|
||||
/// A Jingle thumbnail.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::JINGLE_THUMBNAILS, name = "thumbnail")]
|
||||
pub struct Thumbnail {
|
||||
/// The URI of the thumbnail.
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@
|
|||
// 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 xso::{text::Base64, FromXml, IntoXml};
|
||||
use xso::{text::Base64, AsXml, FromXml};
|
||||
|
||||
use crate::message::MessagePayload;
|
||||
use crate::ns;
|
||||
use crate::pubsub::PubSubPayload;
|
||||
|
||||
/// Element of the device list
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::LEGACY_OMEMO, name = "device")]
|
||||
pub struct Device {
|
||||
/// Device id
|
||||
|
|
@ -33,7 +33,7 @@ impl PubSubPayload for DeviceList {}
|
|||
|
||||
/// SignedPreKey public key
|
||||
/// Part of a device's bundle
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::LEGACY_OMEMO, name = "signedPreKeyPublic")]
|
||||
pub struct SignedPreKeyPublic {
|
||||
/// SignedPreKey id
|
||||
|
|
@ -47,7 +47,7 @@ pub struct SignedPreKeyPublic {
|
|||
|
||||
/// SignedPreKey signature
|
||||
/// Part of a device's bundle
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::LEGACY_OMEMO, name = "signedPreKeySignature")]
|
||||
pub struct SignedPreKeySignature {
|
||||
/// Signature bytes
|
||||
|
|
@ -56,7 +56,7 @@ pub struct SignedPreKeySignature {
|
|||
}
|
||||
|
||||
/// Part of a device's bundle
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::LEGACY_OMEMO, name = "identityKey")]
|
||||
pub struct IdentityKey {
|
||||
/// Serialized PublicKey
|
||||
|
|
@ -76,7 +76,7 @@ generate_element!(
|
|||
|
||||
/// PreKey public key
|
||||
/// Part of a device's bundle
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::LEGACY_OMEMO, name = "preKeyPublic")]
|
||||
pub struct PreKeyPublic {
|
||||
/// PreKey id
|
||||
|
|
@ -123,7 +123,7 @@ generate_element!(
|
|||
);
|
||||
|
||||
/// IV used for payload encryption
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::LEGACY_OMEMO, name = "iv")]
|
||||
pub struct IV {
|
||||
/// IV bytes
|
||||
|
|
@ -139,7 +139,7 @@ generate_attribute!(
|
|||
);
|
||||
|
||||
/// Part of the OMEMO element header
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::LEGACY_OMEMO, name = "key")]
|
||||
pub struct Key {
|
||||
/// The device id this key is encrypted for.
|
||||
|
|
@ -159,7 +159,7 @@ pub struct Key {
|
|||
}
|
||||
|
||||
/// The encrypted message body
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::LEGACY_OMEMO, name = "payload")]
|
||||
pub struct Payload {
|
||||
/// Encrypted with AES-128 in Galois/Counter Mode (GCM)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
use xso::{
|
||||
error::{Error, FromElementError},
|
||||
FromXml, IntoXml,
|
||||
AsXml, FromXml,
|
||||
};
|
||||
|
||||
use crate::data_forms::DataForm;
|
||||
|
|
@ -165,7 +165,7 @@ generate_element!(
|
|||
impl IqResultPayload for Fin {}
|
||||
|
||||
/// Metadata of the first message in the archive.
|
||||
#[derive(FromXml, IntoXml, Debug, Clone, PartialEq)]
|
||||
#[derive(FromXml, AsXml, Debug, Clone, PartialEq)]
|
||||
#[xml(namespace = ns::MAM, name = "start")]
|
||||
pub struct Start {
|
||||
/// The id of the first message in the archive.
|
||||
|
|
@ -178,7 +178,7 @@ pub struct Start {
|
|||
}
|
||||
|
||||
/// Metadata of the last message in the archive.
|
||||
#[derive(FromXml, IntoXml, Debug, Clone, PartialEq)]
|
||||
#[derive(FromXml, AsXml, Debug, Clone, PartialEq)]
|
||||
#[xml(namespace = ns::MAM, name = "end")]
|
||||
pub struct End {
|
||||
/// The id of the last message in the archive.
|
||||
|
|
@ -191,7 +191,7 @@ pub struct End {
|
|||
}
|
||||
|
||||
/// Request an archive for its metadata.
|
||||
#[derive(FromXml, IntoXml, Debug, Clone, PartialEq)]
|
||||
#[derive(FromXml, AsXml, Debug, Clone, PartialEq)]
|
||||
#[xml(namespace = ns::MAM, name = "metadata")]
|
||||
pub struct MetadataQuery;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@
|
|||
// 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 xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use crate::message::MessagePayload;
|
||||
use crate::ns;
|
||||
|
||||
/// Defines that the message containing this payload should replace a
|
||||
/// previous message, identified by the id.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::MESSAGE_CORRECT, name = "replace")]
|
||||
pub struct Replace {
|
||||
/// The 'id' attribute of the message getting corrected.
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
// TODO: validate nicks by applying the “nickname” profile of the PRECIS OpaqueString class, as
|
||||
// defined in RFC 7700.
|
||||
|
||||
use xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use crate::iq::{IqResultPayload, IqSetPayload};
|
||||
use crate::message::MessagePayload;
|
||||
|
|
@ -59,7 +59,7 @@ impl Participant {
|
|||
}
|
||||
|
||||
/// A node to subscribe to.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::MIX_CORE, name = "subscribe")]
|
||||
pub struct Subscribe {
|
||||
/// The PubSub node to subscribe to.
|
||||
|
|
@ -151,7 +151,7 @@ impl UpdateSubscription {
|
|||
|
||||
/// Request to leave a given MIX channel. It will automatically unsubscribe the user from all
|
||||
/// nodes on this channel.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::MIX_CORE, name = "leave")]
|
||||
pub struct Leave;
|
||||
|
||||
|
|
@ -204,7 +204,7 @@ impl Mix {
|
|||
}
|
||||
|
||||
/// Create a new MIX channel.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Clone, Debug, Default)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Clone, Debug, Default)]
|
||||
#[xml(namespace = ns::MIX_CORE, name = "create")]
|
||||
pub struct Create {
|
||||
/// The requested channel identifier.
|
||||
|
|
@ -230,7 +230,7 @@ impl Create {
|
|||
}
|
||||
|
||||
/// Destroy a given MIX channel.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::MIX_CORE, name = "destroy")]
|
||||
pub struct Destroy {
|
||||
/// The channel identifier to be destroyed.
|
||||
|
|
|
|||
|
|
@ -5,14 +5,14 @@
|
|||
// 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 xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use crate::date::DateTime;
|
||||
use crate::ns;
|
||||
use crate::presence::PresencePayload;
|
||||
|
||||
/// Represents the query for messages before our join.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone, Default)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone, Default)]
|
||||
#[xml(namespace = ns::MUC, name = "history")]
|
||||
pub struct History {
|
||||
/// How many characters of history to send, in XML characters.
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
use xso::{
|
||||
error::{Error, FromElementError},
|
||||
FromXml, IntoXml,
|
||||
AsXml, FromXml,
|
||||
};
|
||||
|
||||
use crate::message::MessagePayload;
|
||||
|
|
@ -131,7 +131,7 @@ impl From<Actor> for Element {
|
|||
|
||||
/// Used to continue a one-to-one discussion in a room, with more than one
|
||||
/// participant.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::MUC_USER, name = "continue")]
|
||||
pub struct Continue {
|
||||
/// The thread to continue in this room.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
// 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 xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use crate::message::MessagePayload;
|
||||
use crate::ns;
|
||||
|
|
@ -14,7 +14,7 @@ use crate::presence::PresencePayload;
|
|||
///
|
||||
/// It allows clients to identify a MUC participant across reconnects and
|
||||
/// renames. It thus prevents impersonification of anonymous users.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::OID, name = "occupant-id")]
|
||||
pub struct OccupantId {
|
||||
/// The id associated to the sending user by the MUC service.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
// 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 xso::{text::Base64, FromXml, IntoXml};
|
||||
use xso::{text::Base64, AsXml, FromXml};
|
||||
|
||||
use crate::date::DateTime;
|
||||
use crate::ns;
|
||||
|
|
@ -12,7 +12,7 @@ use crate::pubsub::PubSubPayload;
|
|||
|
||||
/// Data contained in the PubKey element
|
||||
// TODO: Merge this container with the PubKey struct
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::OX, name = "data")]
|
||||
pub struct PubKeyData {
|
||||
/// Base64 data
|
||||
|
|
@ -36,7 +36,7 @@ generate_element!(
|
|||
impl PubSubPayload for PubKey {}
|
||||
|
||||
/// Public key metadata
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::OX, name = "pubkey-metadata")]
|
||||
pub struct PubKeyMeta {
|
||||
/// OpenPGP v4 fingerprint
|
||||
|
|
|
|||
|
|
@ -5,14 +5,14 @@
|
|||
// 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 xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use crate::iq::IqGetPayload;
|
||||
use crate::ns;
|
||||
|
||||
/// Represents a ping to the recipient, which must be answered with an
|
||||
/// empty `<iq/>` or with an error.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::PING, name = "ping")]
|
||||
pub struct Ping;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
// 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 xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use crate::data_forms::DataForm;
|
||||
use crate::iq::{IqGetPayload, IqResultPayload, IqSetPayload};
|
||||
|
|
@ -29,7 +29,7 @@ generate_element!(
|
|||
);
|
||||
|
||||
/// An affiliation element.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::PUBSUB_OWNER, name = "affiliation")]
|
||||
pub struct Affiliation {
|
||||
/// The node this affiliation pertains to.
|
||||
|
|
@ -77,7 +77,7 @@ generate_element!(
|
|||
);
|
||||
|
||||
/// A redirect element.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::PUBSUB_OWNER, name = "redirect")]
|
||||
pub struct Redirect {
|
||||
/// The node this node will be redirected to.
|
||||
|
|
@ -86,7 +86,7 @@ pub struct Redirect {
|
|||
}
|
||||
|
||||
/// Request to clear a node.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::PUBSUB_OWNER, name = "purge")]
|
||||
pub struct Purge {
|
||||
/// The node to be cleared.
|
||||
|
|
@ -108,7 +108,7 @@ generate_element!(
|
|||
);
|
||||
|
||||
/// A subscription element, describing the state of a subscription.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::PUBSUB_OWNER, name = "subscription")]
|
||||
pub struct SubscriptionElem {
|
||||
/// The JID affected by this subscription.
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
use xso::{
|
||||
error::{Error, FromElementError},
|
||||
FromXml, IntoXml,
|
||||
AsXml, FromXml,
|
||||
};
|
||||
|
||||
use crate::data_forms::DataForm;
|
||||
|
|
@ -34,7 +34,7 @@ generate_element!(
|
|||
);
|
||||
|
||||
/// An affiliation element.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::PUBSUB, name = "affiliation")]
|
||||
pub struct Affiliation {
|
||||
/// The node this affiliation pertains to.
|
||||
|
|
@ -56,7 +56,7 @@ generate_element!(
|
|||
);
|
||||
|
||||
/// Request to create a new node.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::PUBSUB, name = "create")]
|
||||
pub struct Create {
|
||||
/// The node name to create, if `None` the service will generate one.
|
||||
|
|
@ -222,7 +222,7 @@ impl From<SubscribeOptions> for Element {
|
|||
}
|
||||
|
||||
/// A request to subscribe a JID to a node.
|
||||
#[derive(FromXml, IntoXml, Debug, PartialEq, Clone)]
|
||||
#[derive(FromXml, AsXml, Debug, PartialEq, Clone)]
|
||||
#[xml(namespace = ns::PUBSUB, name = "subscribe")]
|
||||
pub struct Subscribe {
|
||||
/// The JID being subscribed.
|
||||
|
|
@ -270,7 +270,7 @@ generate_element!(
|
|||
);
|
||||
|
||||
/// An unsubscribe request.
|
||||
#[derive(FromXml, IntoXml, Debug, PartialEq, Clone)]
|
||||
#[derive(FromXml, AsXml, Debug, PartialEq, Clone)]
|
||||
#[xml(namespace = ns::PUBSUB, name = "unsubscribe")]
|
||||
pub struct Unsubscribe {
|
||||
/// The JID affected by this request.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
// 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 xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use crate::message::MessagePayload;
|
||||
use crate::ns;
|
||||
|
|
@ -25,7 +25,7 @@ generate_element!(
|
|||
impl MessagePayload for Reactions {}
|
||||
|
||||
/// One emoji reaction.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::REACTIONS, name = "reaction")]
|
||||
pub struct Reaction {
|
||||
/// The text of this reaction.
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@
|
|||
// 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 xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use crate::message::MessagePayload;
|
||||
use crate::ns;
|
||||
|
||||
/// Requests that this message is acked by the final recipient once
|
||||
/// received.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::RECEIPTS, name = "request")]
|
||||
pub struct Request;
|
||||
|
||||
|
|
@ -19,7 +19,7 @@ impl MessagePayload for Request {}
|
|||
|
||||
/// Notes that a previous message has correctly been received, it is
|
||||
/// referenced by its 'id' attribute.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::RECEIPTS, name = "received")]
|
||||
pub struct Received {
|
||||
/// The 'id' attribute of the received message.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
// 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 xso::{text::EmptyAsNone, FromXml, IntoXml};
|
||||
use xso::{text::EmptyAsNone, AsXml, FromXml};
|
||||
|
||||
use crate::ns;
|
||||
use crate::Element;
|
||||
|
|
@ -31,7 +31,7 @@ generate_attribute!(
|
|||
);
|
||||
|
||||
/// Supports the transmission of text, including key presses, and text block inserts.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::RTT, name = "t")]
|
||||
pub struct Insert {
|
||||
/// Position in the message to start inserting from. If None, this means to start from the
|
||||
|
|
@ -113,7 +113,7 @@ impl TryFrom<Action> for Erase {
|
|||
|
||||
/// Allow for the transmission of intervals, between real-time text actions, to recreate the
|
||||
/// pauses between key presses.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::RTT, name = "w")]
|
||||
pub struct Wait {
|
||||
/// Amount of milliseconds to wait before the next action.
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
use xso::{
|
||||
error::{Error, FromElementError},
|
||||
text::Base64,
|
||||
FromXml, IntoXml,
|
||||
AsXml, FromXml,
|
||||
};
|
||||
|
||||
use crate::ns;
|
||||
|
|
@ -48,7 +48,7 @@ generate_attribute!(
|
|||
|
||||
/// The first step of the SASL process, selecting the mechanism and sending
|
||||
/// the first part of the handshake.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::SASL, name = "auth")]
|
||||
pub struct Auth {
|
||||
/// The mechanism used.
|
||||
|
|
@ -63,7 +63,7 @@ pub struct Auth {
|
|||
/// In case the mechanism selected at the [auth](struct.Auth.html) step
|
||||
/// requires a second step, the server sends this element with additional
|
||||
/// data.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::SASL, name = "challenge")]
|
||||
pub struct Challenge {
|
||||
/// The challenge data.
|
||||
|
|
@ -74,7 +74,7 @@ pub struct Challenge {
|
|||
/// In case the mechanism selected at the [auth](struct.Auth.html) step
|
||||
/// requires a second step, this contains the client’s response to the
|
||||
/// server’s [challenge](struct.Challenge.html).
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::SASL, name = "response")]
|
||||
pub struct Response {
|
||||
/// The response data.
|
||||
|
|
@ -84,12 +84,12 @@ pub struct Response {
|
|||
|
||||
/// Sent by the client at any point after [auth](struct.Auth.html) if it
|
||||
/// wants to cancel the current authentication process.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::SASL, name = "abort")]
|
||||
pub struct Abort;
|
||||
|
||||
/// Sent by the server on SASL success.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::SASL, name = "success")]
|
||||
pub struct Success {
|
||||
/// Possible data sent on success.
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@
|
|||
// 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 xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use crate::ns;
|
||||
use crate::stanza_error::DefinedCondition;
|
||||
|
||||
/// Acknowledgement of the currently received stanzas.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::SM, name = "a")]
|
||||
pub struct A {
|
||||
/// The last handled stanza.
|
||||
|
|
@ -105,12 +105,12 @@ generate_element!(
|
|||
);
|
||||
|
||||
/// Requests the currently received stanzas by the other party.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::SM, name = "r")]
|
||||
pub struct R;
|
||||
|
||||
/// Requests a stream resumption.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::SM, name = "resume")]
|
||||
pub struct Resume {
|
||||
/// The last handled stanza.
|
||||
|
|
@ -124,7 +124,7 @@ pub struct Resume {
|
|||
}
|
||||
|
||||
/// The response by the server for a successfully resumed stream.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::SM, name = "resumed")]
|
||||
pub struct Resumed {
|
||||
/// The last handled stanza.
|
||||
|
|
@ -139,7 +139,7 @@ pub struct Resumed {
|
|||
|
||||
// TODO: add support for optional and required.
|
||||
/// Represents availability of Stream Management in `<stream:features/>`.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::SM, name = "sm")]
|
||||
pub struct StreamManagement;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
// 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 xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use crate::message::MessagePayload;
|
||||
use crate::ns;
|
||||
|
|
@ -12,7 +12,7 @@ use jid::Jid;
|
|||
|
||||
/// Gives the identifier a service has stamped on this stanza, often in
|
||||
/// order to identify it inside of [an archive](../mam/index.html).
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::SID, name = "stanza-id")]
|
||||
pub struct StanzaId {
|
||||
/// The id associated to this stanza by another entity.
|
||||
|
|
@ -28,7 +28,7 @@ impl MessagePayload for StanzaId {}
|
|||
|
||||
/// A hack for MUC before version 1.31 to track a message which may have
|
||||
/// its 'id' attribute changed.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::SID, name = "origin-id")]
|
||||
pub struct OriginId {
|
||||
/// The id this client set for this stanza.
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@
|
|||
// 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 xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use jid::BareJid;
|
||||
|
||||
use crate::ns;
|
||||
|
||||
/// The stream opening for client-server communications.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::STREAM, name = "stream")]
|
||||
pub struct Stream {
|
||||
/// The JID of the entity opening this stream.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
// 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 xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use crate::date::DateTime;
|
||||
use crate::iq::{IqGetPayload, IqResultPayload};
|
||||
|
|
@ -15,7 +15,7 @@ use std::str::FromStr;
|
|||
use xso::error::{Error, FromElementError};
|
||||
|
||||
/// An entity time query.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::TIME, name = "time")]
|
||||
pub struct TimeQuery;
|
||||
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ mod helpers {
|
|||
// this is to ensure that the macros do not have hidden dependencies on
|
||||
// any specific names being imported.
|
||||
use minidom::Element;
|
||||
use xso::{error::FromElementError, transform, try_from_element, FromXml, IntoXml};
|
||||
use xso::{error::FromElementError, transform, try_from_element, AsXml, FromXml};
|
||||
|
||||
pub(super) fn roundtrip_full<T: IntoXml + FromXml + PartialEq + std::fmt::Debug + Clone>(
|
||||
pub(super) fn roundtrip_full<T: AsXml + FromXml + PartialEq + std::fmt::Debug + Clone>(
|
||||
s: &str,
|
||||
) {
|
||||
let initial: Element = s.parse().unwrap();
|
||||
|
|
@ -47,7 +47,7 @@ mod helpers {
|
|||
|
||||
use self::helpers::{parse_str, roundtrip_full};
|
||||
|
||||
use xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
// these are adverserial local names in order to trigger any issues with
|
||||
// unqualified names in the macro expansions.
|
||||
|
|
@ -81,7 +81,7 @@ static BAR_NAME: &::xso::exports::rxml::strings::NcNameStr = {
|
|||
}
|
||||
};
|
||||
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = NS1, name = "foo")]
|
||||
struct Empty;
|
||||
|
||||
|
|
@ -164,7 +164,7 @@ fn empty_qname_check_has_precedence_over_attr_check() {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = NS1, name = BAR_NAME)]
|
||||
struct NamePath;
|
||||
|
||||
|
|
@ -178,7 +178,7 @@ fn name_path_roundtrip() {
|
|||
roundtrip_full::<NamePath>("<bar xmlns='urn:example:ns1'/>");
|
||||
}
|
||||
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = "urn:example:ns2", name = "baz")]
|
||||
struct NamespaceLit;
|
||||
|
||||
|
|
@ -192,7 +192,7 @@ fn namespace_lit_roundtrip() {
|
|||
roundtrip_full::<NamespaceLit>("<baz xmlns='urn:example:ns2'/>");
|
||||
}
|
||||
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = NS1, name = "attr")]
|
||||
struct RequiredAttribute {
|
||||
#[xml(attribute)]
|
||||
|
|
@ -237,7 +237,7 @@ fn required_attribute_missing() {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = NS1, name = "attr")]
|
||||
struct RenamedAttribute {
|
||||
#[xml(attribute = "a1")]
|
||||
|
|
@ -256,7 +256,7 @@ fn renamed_attribute_roundtrip() {
|
|||
roundtrip_full::<RenamedAttribute>("<attr xmlns='urn:example:ns1' a1='bar' bar='baz'/>");
|
||||
}
|
||||
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = NS1, name = "attr")]
|
||||
struct NamespacedAttribute {
|
||||
#[xml(attribute(namespace = "urn:example:ns1", name = FOO_NAME))]
|
||||
|
|
@ -297,7 +297,7 @@ fn namespaced_attribute_roundtrip_b() {
|
|||
);
|
||||
}
|
||||
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = NS1, name = "attr")]
|
||||
struct PrefixedAttribute {
|
||||
#[xml(attribute = "xml:lang")]
|
||||
|
|
@ -314,7 +314,7 @@ fn prefixed_attribute_roundtrip() {
|
|||
roundtrip_full::<PrefixedAttribute>("<attr xmlns='urn:example:ns1' xml:lang='foo'/>");
|
||||
}
|
||||
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = NS1, name = "attr")]
|
||||
struct RequiredNonStringAttribute {
|
||||
#[xml(attribute)]
|
||||
|
|
@ -331,7 +331,7 @@ fn required_non_string_attribute_roundtrip() {
|
|||
roundtrip_full::<RequiredNonStringAttribute>("<attr xmlns='urn:example:ns1' foo='-16'/>");
|
||||
}
|
||||
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = NS1, name = "attr")]
|
||||
struct DefaultAttribute {
|
||||
#[xml(attribute(default))]
|
||||
|
|
@ -381,7 +381,7 @@ fn default_attribute_roundtrip_pp() {
|
|||
roundtrip_full::<DefaultAttribute>("<attr xmlns='urn:example:ns1' foo='xyz' bar='16'/>");
|
||||
}
|
||||
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = NS1, name = "text")]
|
||||
struct TextString {
|
||||
#[xml(text)]
|
||||
|
|
@ -409,7 +409,7 @@ fn text_string_positive_preserves_whitespace() {
|
|||
assert_eq!(el.text, " \t\n");
|
||||
}
|
||||
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = NS1, name = "text")]
|
||||
struct TextNonString {
|
||||
#[xml(text)]
|
||||
|
|
@ -426,7 +426,7 @@ fn text_non_string_roundtrip() {
|
|||
roundtrip_full::<TextNonString>("<text xmlns='urn:example:ns1'>123456</text>");
|
||||
}
|
||||
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = NS1, name = "elem")]
|
||||
struct IgnoresWhitespaceWithoutTextConsumer;
|
||||
|
||||
|
|
@ -443,7 +443,7 @@ fn ignores_whitespace_without_text_consumer_positive() {
|
|||
.unwrap();
|
||||
}
|
||||
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = NS1, name = "elem")]
|
||||
struct FailsTextWithoutTextConsumer;
|
||||
|
||||
|
|
@ -465,7 +465,7 @@ fn fails_text_without_text_consumer_positive() {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = NS1, name = "text")]
|
||||
struct TextWithCodec {
|
||||
#[xml(text(codec = xso::text::EmptyAsNone))]
|
||||
|
|
|
|||
|
|
@ -94,9 +94,13 @@ macro_rules! generate_attribute {
|
|||
})
|
||||
}
|
||||
}
|
||||
impl ::xso::IntoXmlText for $elem {
|
||||
fn into_xml_text(self) -> Result<String, xso::error::Error> {
|
||||
Ok(self.to_string())
|
||||
impl ::xso::AsXmlText for $elem {
|
||||
fn as_xml_text(&self) -> Result<::std::borrow::Cow<'_, str>, xso::error::Error> {
|
||||
match self {
|
||||
$(
|
||||
$elem::$a => Ok(::std::borrow::Cow::Borrowed($b))
|
||||
),+
|
||||
}
|
||||
}
|
||||
}
|
||||
impl ::minidom::IntoAttributeValue for $elem {
|
||||
|
|
@ -130,16 +134,16 @@ macro_rules! generate_attribute {
|
|||
s.parse().map_err(xso::error::Error::text_parse_error)
|
||||
}
|
||||
}
|
||||
impl ::xso::IntoXmlText for $elem {
|
||||
fn into_xml_text(self) -> Result<String, xso::error::Error> {
|
||||
Ok(String::from(match self {
|
||||
impl ::xso::AsXmlText for $elem {
|
||||
fn as_xml_text(&self) -> Result<std::borrow::Cow<'_, str>, xso::error::Error> {
|
||||
Ok(std::borrow::Cow::Borrowed(match self {
|
||||
$($elem::$a => $b),+
|
||||
}))
|
||||
}
|
||||
|
||||
#[allow(unreachable_patterns)]
|
||||
fn into_optional_xml_text(self) -> Result<Option<String>, xso::error::Error> {
|
||||
Ok(Some(String::from(match self {
|
||||
fn as_optional_xml_text(&self) -> Result<Option<std::borrow::Cow<'_, str>>, xso::error::Error> {
|
||||
Ok(Some(std::borrow::Cow::Borrowed(match self {
|
||||
$elem::$default => return Ok(None),
|
||||
$($elem::$a => $b),+
|
||||
})))
|
||||
|
|
@ -219,17 +223,17 @@ macro_rules! generate_attribute {
|
|||
}
|
||||
}
|
||||
}
|
||||
impl ::xso::IntoXmlText for $elem {
|
||||
fn into_xml_text(self) -> Result<String, xso::error::Error> {
|
||||
impl ::xso::AsXmlText for $elem {
|
||||
fn as_xml_text(&self) -> Result<::std::borrow::Cow<'_, str>, xso::error::Error> {
|
||||
match self {
|
||||
Self::True => Ok("true".to_owned()),
|
||||
Self::False => Ok("false".to_owned()),
|
||||
Self::True => Ok(::std::borrow::Cow::Borrowed("true")),
|
||||
Self::False => Ok(::std::borrow::Cow::Borrowed("false")),
|
||||
}
|
||||
}
|
||||
|
||||
fn into_optional_xml_text(self) -> Result<Option<String>, xso::error::Error> {
|
||||
fn as_optional_xml_text(&self) -> Result<Option<::std::borrow::Cow<'_, str>>, xso::error::Error> {
|
||||
match self {
|
||||
Self::True => Ok(Some("true".to_owned())),
|
||||
Self::True => Ok(Some(::std::borrow::Cow::Borrowed("true"))),
|
||||
Self::False => Ok(None),
|
||||
}
|
||||
}
|
||||
|
|
@ -435,9 +439,9 @@ macro_rules! generate_id {
|
|||
Ok(Self(s))
|
||||
}
|
||||
}
|
||||
impl ::xso::IntoXmlText for $elem {
|
||||
fn into_xml_text(self) ->Result<String, xso::error::Error> {
|
||||
Ok(self.0)
|
||||
impl ::xso::AsXmlText for $elem {
|
||||
fn as_xml_text(&self) ->Result<::std::borrow::Cow<'_, str>, xso::error::Error> {
|
||||
Ok(::std::borrow::Cow::Borrowed(self.0.as_str()))
|
||||
}
|
||||
}
|
||||
impl ::minidom::IntoAttributeValue for $elem {
|
||||
|
|
@ -803,11 +807,11 @@ macro_rules! generate_element {
|
|||
}
|
||||
}
|
||||
|
||||
impl ::xso::IntoXml for $elem {
|
||||
type EventIter = ::xso::minidom_compat::IntoEventsViaElement;
|
||||
impl ::xso::AsXml for $elem {
|
||||
type ItemIter<'x> = ::xso::minidom_compat::AsItemsViaElement<'x>;
|
||||
|
||||
fn into_event_iter(self) -> Result<Self::EventIter, ::xso::error::Error> {
|
||||
Self::EventIter::new(self)
|
||||
fn as_xml_iter(&self) -> Result<Self::ItemIter<'_>, ::xso::error::Error> {
|
||||
::xso::minidom_compat::AsItemsViaElement::new(self.clone())
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
//! For vCard updates defined in [XEP-0153](https://xmpp.org/extensions/xep-0153.html),
|
||||
//! see [`vcard_update`][crate::vcard_update] module.
|
||||
|
||||
use xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use crate::iq::{IqGetPayload, IqResultPayload, IqSetPayload};
|
||||
use crate::util::text_node_codecs::{Codec, WhitespaceAwareBase64};
|
||||
|
|
@ -33,7 +33,7 @@ generate_element!(
|
|||
);
|
||||
|
||||
/// The type of the photo.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::VCARD, name = "TYPE")]
|
||||
pub struct Type {
|
||||
/// The type as a plain text string; at least "image/jpeg", "image/gif" and "image/png" SHOULD be supported.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
// 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 xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use crate::iq::{IqGetPayload, IqResultPayload};
|
||||
use crate::ns;
|
||||
|
|
@ -13,7 +13,7 @@ use crate::ns;
|
|||
///
|
||||
/// It should only be used in an `<iq type='get'/>`, as it can only
|
||||
/// represent the request, and not a result.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::VERSION, name = "query")]
|
||||
pub struct VersionQuery;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@
|
|||
// 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 xso::{FromXml, IntoXml};
|
||||
use xso::{AsXml, FromXml};
|
||||
|
||||
use jid::BareJid;
|
||||
|
||||
use crate::ns;
|
||||
|
||||
/// The stream opening for WebSocket.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::WEBSOCKET, name = "open")]
|
||||
pub struct Open {
|
||||
/// The JID of the entity opening this stream.
|
||||
|
|
|
|||
Loading…
Reference in a new issue