parsers: use derive macros for simple text-based elements

This commit is contained in:
Jonas Schäfer 2024-06-26 18:05:13 +02:00
commit 298bf006bf
3 changed files with 43 additions and 35 deletions

View file

@ -13,8 +13,10 @@
//! For vCard updates defined in [XEP-0153](https://xmpp.org/extensions/xep-0153.html),
//! see [`vcard_update`][crate::vcard_update] module.
use xso::{FromXml, IntoXml};
use crate::iq::{IqGetPayload, IqResultPayload, IqSetPayload};
use crate::util::text_node_codecs::{Codec, Text, WhitespaceAwareBase64};
use crate::util::text_node_codecs::{Codec, WhitespaceAwareBase64};
use crate::{ns, Error};
use minidom::Element;
@ -30,14 +32,14 @@ generate_element!(
]
);
generate_element!(
/// The type of the photo.
Type, "TYPE", VCARD,
text: (
/// The type as a plain text string; at least "image/jpeg", "image/gif" and "image/png" SHOULD be supported.
data: Text
)
);
/// The type of the photo.
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
#[xml(namespace = ns::VCARD, name = "TYPE")]
pub struct Type {
/// The type as a plain text string; at least "image/jpeg", "image/gif" and "image/png" SHOULD be supported.
#[xml(text)]
pub data: String,
}
generate_element!(
/// The binary data of the photo.