xmpp-parsers: Convert vcard to xso

This commit is contained in:
Emmanuel Gil Peyrot 2024-07-24 17:24:19 +02:00 committed by Maxime “pep” Buquet
commit a2ece705cc

View file

@ -13,11 +13,14 @@
//! For vCard updates defined in [XEP-0153](https://xmpp.org/extensions/xep-0153.html), //! For vCard updates defined in [XEP-0153](https://xmpp.org/extensions/xep-0153.html),
//! see [`vcard_update`][crate::vcard_update] module. //! see [`vcard_update`][crate::vcard_update] module.
use xso::{error::Error, AsXml, FromXml}; use xso::{
error::Error,
text::{Base64, StripWhitespace},
AsXml, FromXml,
};
use crate::iq::{IqGetPayload, IqResultPayload, IqSetPayload}; use crate::iq::{IqGetPayload, IqResultPayload, IqSetPayload};
use crate::ns; use crate::ns;
use crate::util::text_node_codecs::{Codec, WhitespaceAwareBase64};
use minidom::Element; use minidom::Element;
generate_element!( generate_element!(
@ -41,14 +44,14 @@ pub struct Type {
pub data: String, pub data: String,
} }
generate_element!( /// The binary data of the photo.
/// The binary data of the photo. #[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
Binval, "BINVAL", VCARD, #[xml(namespace = ns::VCARD, name = "BINVAL")]
text: ( pub struct Binval {
/// The actual data. /// The actual data.
data: WhitespaceAwareBase64 #[xml(text(codec = Base64<StripWhitespace>))]
) pub data: Vec<u8>,
); }
/// A `<vCard>` element; only the `<PHOTO>` element is supported for this legacy vCard ; the rest is ignored. /// A `<vCard>` element; only the `<PHOTO>` element is supported for this legacy vCard ; the rest is ignored.
pub struct VCard { pub struct VCard {