xmpp-parsers: Convert vcard_update to xso

This commit is contained in:
Emmanuel Gil Peyrot 2024-07-24 16:29:31 +02:00 committed by Maxime “pep” Buquet
parent 16204a1092
commit 8a48244bc3

View file

@ -12,7 +12,9 @@
//! For [XEP-0054](https://xmpp.org/extensions/xep-0054.html) vCard support, //! For [XEP-0054](https://xmpp.org/extensions/xep-0054.html) vCard support,
//! see [`vcard`][crate::vcard] module. //! see [`vcard`][crate::vcard] module.
use crate::util::text_node_codecs::{Codec, FixedHex, OptionalCodec}; use xso::{text::FixedHex, AsXml, FromXml};
use crate::ns;
generate_element!( generate_element!(
/// The presence payload for an avatar VCard update /// The presence payload for an avatar VCard update
@ -23,14 +25,14 @@ generate_element!(
] ]
); );
generate_element!( /// The photo element containing the avatar metadata
/// The photo element containing the avatar metadata #[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
Photo, "photo", VCARD_UPDATE, #[xml(namespace = ns::VCARD_UPDATE, name = "photo")]
text: ( pub struct Photo {
/// The SHA1 hash of the avatar. Empty when there is no photo. /// The SHA1 hash of the avatar. Empty when there is no photo.
data: OptionalCodec<FixedHex<20>> #[xml(text(codec = FixedHex<20>))]
) pub data: Option<[u8; 20]>,
); }
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {