xmpp-parsers: Convert ext disco and Jingle ICE-UDP to xso
This commit is contained in:
parent
df63c2a78f
commit
7ab375fad7
2 changed files with 71 additions and 60 deletions
|
|
@ -56,47 +56,57 @@ generate_attribute!(
|
||||||
bool
|
bool
|
||||||
);
|
);
|
||||||
|
|
||||||
generate_element!(
|
|
||||||
/// Structure representing a `<service xmlns='urn:xmpp:extdisco:2'/>` element.
|
/// Structure representing a `<service xmlns='urn:xmpp:extdisco:2'/>` element.
|
||||||
Service, "service", EXT_DISCO,
|
#[derive(FromXml, AsXml, Debug, PartialEq, Clone)]
|
||||||
attributes: [
|
#[xml(namespace = ns::EXT_DISCO, name = "service")]
|
||||||
|
pub struct Service {
|
||||||
/// When sending a push update, the action value indicates if the service is being added or
|
/// When sending a push update, the action value indicates if the service is being added or
|
||||||
/// deleted from the set of known services (or simply being modified).
|
/// deleted from the set of known services (or simply being modified).
|
||||||
action: Default<Action> = "action",
|
#[xml(attribute(default))]
|
||||||
|
action: Action,
|
||||||
|
|
||||||
/// A timestamp indicating when the provided username and password credentials will expire.
|
/// A timestamp indicating when the provided username and password credentials will expire.
|
||||||
expires: Option<DateTime> = "expires",
|
#[xml(attribute(default))]
|
||||||
|
expires: Option<DateTime>,
|
||||||
|
|
||||||
/// Either a fully qualified domain name (FQDN) or an IP address (IPv4 or IPv6).
|
/// Either a fully qualified domain name (FQDN) or an IP address (IPv4 or IPv6).
|
||||||
host: Required<String> = "host",
|
#[xml(attribute)]
|
||||||
|
host: String,
|
||||||
|
|
||||||
/// A friendly (human-readable) name or label for the service.
|
/// A friendly (human-readable) name or label for the service.
|
||||||
name: Option<String> = "name",
|
#[xml(attribute(default))]
|
||||||
|
name: Option<String>,
|
||||||
|
|
||||||
/// A service- or server-generated password for use at the service.
|
/// A service- or server-generated password for use at the service.
|
||||||
password: Option<String> = "password",
|
#[xml(attribute(default))]
|
||||||
|
password: Option<String>,
|
||||||
|
|
||||||
/// The communications port to be used at the host.
|
/// The communications port to be used at the host.
|
||||||
port: Option<u16> = "port",
|
#[xml(attribute(default))]
|
||||||
|
port: Option<u16>,
|
||||||
|
|
||||||
/// A boolean value indicating that username and password credentials are required and will
|
/// A boolean value indicating that username and password credentials are required and will
|
||||||
/// need to be requested if not already provided.
|
/// need to be requested if not already provided.
|
||||||
restricted: Default<Restricted> = "restricted",
|
#[xml(attribute(default))]
|
||||||
|
restricted: Restricted,
|
||||||
|
|
||||||
/// The underlying transport protocol to be used when communicating with the service (typically
|
/// The underlying transport protocol to be used when communicating with the service (typically
|
||||||
/// either TCP or UDP).
|
/// either TCP or UDP).
|
||||||
transport: Option<Transport> = "transport",
|
#[xml(attribute(default))]
|
||||||
|
transport: Option<Transport>,
|
||||||
|
|
||||||
/// The service type as registered with the XMPP Registrar.
|
/// The service type as registered with the XMPP Registrar.
|
||||||
type_: Required<Type> = "type",
|
#[xml(attribute = "type")]
|
||||||
|
type_: Type,
|
||||||
|
|
||||||
/// A service- or server-generated username for use at the service.
|
/// A service- or server-generated username for use at the service.
|
||||||
username: Option<String> = "username",
|
#[xml(attribute(default))]
|
||||||
], children: [
|
username: Option<String>,
|
||||||
|
|
||||||
/// Extended information
|
/// Extended information
|
||||||
ext_info: Vec<DataForm> = ("x", DATA_FORMS) => DataForm
|
#[xml(child(n = ..))]
|
||||||
]
|
ext_info: Vec<DataForm>,
|
||||||
);
|
}
|
||||||
|
|
||||||
impl IqGetPayload for Service {}
|
impl IqGetPayload for Service {}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,25 +11,26 @@ use xso::{AsXml, FromXml};
|
||||||
use crate::jingle_dtls_srtp::Fingerprint;
|
use crate::jingle_dtls_srtp::Fingerprint;
|
||||||
use crate::ns;
|
use crate::ns;
|
||||||
|
|
||||||
generate_element!(
|
|
||||||
/// Wrapper element for an ICE-UDP transport.
|
/// Wrapper element for an ICE-UDP transport.
|
||||||
#[derive(Default)]
|
#[derive(FromXml, AsXml, Debug, PartialEq, Clone, Default)]
|
||||||
Transport, "transport", JINGLE_ICE_UDP,
|
#[xml(namespace = ns::JINGLE_ICE_UDP, name = "transport")]
|
||||||
attributes: [
|
pub struct Transport {
|
||||||
/// A Password as defined in ICE-CORE.
|
/// A Password as defined in ICE-CORE.
|
||||||
pwd: Option<String> = "pwd",
|
#[xml(attribute(default))]
|
||||||
|
pwd: Option<String>,
|
||||||
|
|
||||||
/// A User Fragment as defined in ICE-CORE.
|
/// A User Fragment as defined in ICE-CORE.
|
||||||
ufrag: Option<String> = "ufrag",
|
#[xml(attribute(default))]
|
||||||
],
|
ufrag: Option<String>,
|
||||||
children: [
|
|
||||||
/// List of candidates for this ICE-UDP session.
|
/// List of candidates for this ICE-UDP session.
|
||||||
candidates: Vec<Candidate> = ("candidate", JINGLE_ICE_UDP) => Candidate,
|
#[xml(child(n = ..))]
|
||||||
|
candidates: Vec<Candidate>,
|
||||||
|
|
||||||
/// Fingerprint of the key used for the DTLS handshake.
|
/// Fingerprint of the key used for the DTLS handshake.
|
||||||
fingerprint: Option<Fingerprint> = ("fingerprint", JINGLE_DTLS) => Fingerprint
|
#[xml(child(default))]
|
||||||
]
|
fingerprint: Option<Fingerprint>,
|
||||||
);
|
}
|
||||||
|
|
||||||
impl Transport {
|
impl Transport {
|
||||||
/// Create a new ICE-UDP transport.
|
/// Create a new ICE-UDP transport.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue