xmpp-parsers: Convert jingle_s5b’s Candidate to xso
This commit is contained in:
parent
726801610f
commit
09c5ad5976
1 changed files with 29 additions and 20 deletions
|
|
@ -4,11 +4,15 @@
|
||||||
// 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 xso::{
|
||||||
|
error::{Error, FromElementError},
|
||||||
|
AsXml, FromXml,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::ns;
|
use crate::ns;
|
||||||
use jid::Jid;
|
use jid::Jid;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use std::net::IpAddr;
|
use std::net::IpAddr;
|
||||||
use xso::error::{Error, FromElementError};
|
|
||||||
|
|
||||||
generate_attribute!(
|
generate_attribute!(
|
||||||
/// The type of the connection being proposed by this candidate.
|
/// The type of the connection being proposed by this candidate.
|
||||||
|
|
@ -49,30 +53,35 @@ generate_id!(
|
||||||
StreamId
|
StreamId
|
||||||
);
|
);
|
||||||
|
|
||||||
generate_element!(
|
/// A candidate for a connection.
|
||||||
/// A candidate for a connection.
|
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||||
Candidate, "candidate", JINGLE_S5B,
|
#[xml(namespace = ns::JINGLE_S5B, name = "candidate")]
|
||||||
attributes: [
|
pub struct Candidate {
|
||||||
/// The identifier for this candidate.
|
/// The identifier for this candidate.
|
||||||
cid: Required<CandidateId> = "cid",
|
#[xml(attribute)]
|
||||||
|
cid: CandidateId,
|
||||||
|
|
||||||
/// The host to connect to.
|
/// The host to connect to.
|
||||||
host: Required<IpAddr> = "host",
|
#[xml(attribute)]
|
||||||
|
host: IpAddr,
|
||||||
|
|
||||||
/// The JID to request at the given end.
|
/// The JID to request at the given end.
|
||||||
jid: Required<Jid> = "jid",
|
#[xml(attribute)]
|
||||||
|
jid: Jid,
|
||||||
|
|
||||||
/// The port to connect to.
|
/// The port to connect to.
|
||||||
port: Option<u16> = "port",
|
#[xml(attribute(default))]
|
||||||
|
port: Option<u16>,
|
||||||
|
|
||||||
/// The priority of this candidate, computed using this formula:
|
/// The priority of this candidate, computed using this formula:
|
||||||
/// priority = (2^16)*(type preference) + (local preference)
|
/// priority = (2^16)*(type preference) + (local preference)
|
||||||
priority: Required<u32> = "priority",
|
#[xml(attribute)]
|
||||||
|
priority: u32,
|
||||||
|
|
||||||
/// The type of the connection being proposed by this candidate.
|
/// The type of the connection being proposed by this candidate.
|
||||||
type_: Default<Type> = "type",
|
#[xml(attribute(default, name = "type"))]
|
||||||
]
|
type_: Type,
|
||||||
);
|
}
|
||||||
|
|
||||||
impl Candidate {
|
impl Candidate {
|
||||||
/// Creates a new candidate with the given parameters.
|
/// Creates a new candidate with the given parameters.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue