mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 22:52:22 +00:00
rustical_xml: Add new trait EnumVariants
This commit is contained in:
36
crates/xml/tests/enum_variants.rs
Normal file
36
crates/xml/tests/enum_variants.rs
Normal file
@@ -0,0 +1,36 @@
|
||||
use quick_xml::name::Namespace;
|
||||
use rustical_xml::EnumVariants;
|
||||
|
||||
pub const NS_DAV: Namespace = Namespace(b"DAV:");
|
||||
pub const NS_DAVPUSH: Namespace = Namespace(b"https://bitfire.at/webdav-push");
|
||||
pub const NS_CALDAV: Namespace = Namespace(b"urn:ietf:params:xml:ns:caldav");
|
||||
pub const NS_CARDDAV: Namespace = Namespace(b"urn:ietf:params:xml:ns:carddav");
|
||||
pub const NS_ICAL: Namespace = Namespace(b"http://apple.com/ns/ical/");
|
||||
pub const NS_CALENDARSERVER: Namespace = Namespace(b"http://calendarserver.org/ns/");
|
||||
pub const NS_NEXTCLOUD: Namespace = Namespace(b"http://nextcloud.com/ns");
|
||||
|
||||
#[derive(EnumVariants)]
|
||||
pub enum CalendarProp {
|
||||
// WebDAV (RFC 2518)
|
||||
#[xml(ns = "NS_DAV")]
|
||||
Displayname(Option<String>),
|
||||
#[xml(ns = "NS_DAV")]
|
||||
Getcontenttype(&'static str),
|
||||
|
||||
#[xml(ns = "NS_DAV", rename = b"principal-URL")]
|
||||
PrincipalUrl,
|
||||
Topic,
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_enum_variants() {
|
||||
assert_eq!(
|
||||
CalendarProp::TAGGED_VARIANTS,
|
||||
&[
|
||||
(Some(NS_DAV), "displayname"),
|
||||
(Some(NS_DAV), "getcontenttype"),
|
||||
(Some(NS_DAV), "principal-URL"),
|
||||
(None, "topic"),
|
||||
]
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user