xmpp-parsers: Convert jingle_dtls_srtp to xso

This commit is contained in:
Emmanuel Gil Peyrot 2024-07-24 16:31:53 +02:00 committed by Maxime “pep” Buquet
commit dc0db38cf3

View file

@ -4,8 +4,10 @@
// 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::{text::ColonSeparatedHex, AsXml, FromXml};
use crate::hashes::{Algo, Hash}; use crate::hashes::{Algo, Hash};
use crate::util::text_node_codecs::{Codec, ColonSeparatedHex}; use crate::ns;
use xso::error::Error; use xso::error::Error;
generate_attribute!( generate_attribute!(
@ -31,21 +33,22 @@ generate_attribute!(
); );
// TODO: use a hashes::Hash instead of two different fields here. // TODO: use a hashes::Hash instead of two different fields here.
generate_element!(
/// Fingerprint of the key used for a DTLS handshake. /// Fingerprint of the key used for a DTLS handshake.
Fingerprint, "fingerprint", JINGLE_DTLS, #[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
attributes: [ #[xml(namespace = ns::JINGLE_DTLS, name = "fingerprint")]
pub struct Fingerprint {
/// The hash algorithm used for this fingerprint. /// The hash algorithm used for this fingerprint.
hash: Required<Algo> = "hash", #[xml(attribute)]
pub hash: Algo,
/// Indicates which of the end points should initiate the TCP connection establishment. /// Indicates which of the end points should initiate the TCP connection establishment.
setup: Required<Setup> = "setup" #[xml(attribute)]
], pub setup: Setup,
text: (
/// Hash value of this fingerprint. /// Hash value of this fingerprint.
value: ColonSeparatedHex #[xml(text(codec = ColonSeparatedHex))]
) pub value: Vec<u8>,
); }
impl Fingerprint { impl Fingerprint {
/// Create a new Fingerprint from a Setup and a Hash. /// Create a new Fingerprint from a Setup and a Hash.