From a2ece705cc1c68fa0e5a6246320daf5ce67638c2 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Wed, 24 Jul 2024 17:24:19 +0200 Subject: [PATCH] xmpp-parsers: Convert vcard to xso --- parsers/src/vcard.rs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/parsers/src/vcard.rs b/parsers/src/vcard.rs index 72d8640a..9c335412 100644 --- a/parsers/src/vcard.rs +++ b/parsers/src/vcard.rs @@ -13,11 +13,14 @@ //! For vCard updates defined in [XEP-0153](https://xmpp.org/extensions/xep-0153.html), //! 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::ns; -use crate::util::text_node_codecs::{Codec, WhitespaceAwareBase64}; use minidom::Element; generate_element!( @@ -41,14 +44,14 @@ pub struct Type { pub data: String, } -generate_element!( - /// The binary data of the photo. - Binval, "BINVAL", VCARD, - text: ( - /// The actual data. - data: WhitespaceAwareBase64 - ) -); +/// The binary data of the photo. +#[derive(FromXml, AsXml, PartialEq, Debug, Clone)] +#[xml(namespace = ns::VCARD, name = "BINVAL")] +pub struct Binval { + /// The actual data. + #[xml(text(codec = Base64))] + pub data: Vec, +} /// A `` element; only the `` element is supported for this legacy vCard ; the rest is ignored. pub struct VCard {