xmpp-parsers: Convert bookmarks to xso

This commit is contained in:
Emmanuel Gil Peyrot 2024-08-04 17:42:01 +02:00 committed by Jonas Schäfer
commit 79e224a02a

View file

@ -23,27 +23,30 @@ use jid::BareJid;
pub use crate::bookmarks2::Autojoin; pub use crate::bookmarks2::Autojoin;
use crate::ns; use crate::ns;
generate_element!( /// A conference bookmark.
/// A conference bookmark. #[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
Conference, "conference", BOOKMARKS, #[xml(namespace = ns::BOOKMARKS, name = "conference")]
attributes: [ pub struct Conference {
/// Whether a conference bookmark should be joined automatically. /// Whether a conference bookmark should be joined automatically.
autojoin: Default<Autojoin> = "autojoin", #[xml(attribute(default))]
pub autojoin: Autojoin,
/// The JID of the conference. /// The JID of the conference.
jid: Required<BareJid> = "jid", #[xml(attribute)]
pub jid: BareJid,
/// A user-defined name for this conference. /// A user-defined name for this conference.
name: Option<String> = "name", #[xml(attribute(default))]
], pub name: Option<String>,
children: [
/// The nick the user will use to join this conference.
nick: Option<String> = ("nick", BOOKMARKS) => String,
/// The password required to join this conference. /// The nick the user will use to join this conference.
password: Option<String> = ("password", BOOKMARKS) => String #[xml(extract(default, fields(text(type_ = String))))]
] pub nick: Option<String>,
);
/// The password required to join this conference.
#[xml(extract(default, fields(text(type_ = String))))]
pub password: Option<String>,
}
impl Conference { impl Conference {
/// Turns a XEP-0048 Conference element into a XEP-0402 "Bookmarks2" Conference element, in a /// Turns a XEP-0048 Conference element into a XEP-0402 "Bookmarks2" Conference element, in a