mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 22:52:22 +00:00
principal: Implement principal-collection-set
This commit is contained in:
@@ -22,8 +22,11 @@ pub use error::Error;
|
|||||||
pub struct CalDavPrincipalUri(&'static str);
|
pub struct CalDavPrincipalUri(&'static str);
|
||||||
|
|
||||||
impl PrincipalUri for CalDavPrincipalUri {
|
impl PrincipalUri for CalDavPrincipalUri {
|
||||||
|
fn principal_collection(&self) -> String {
|
||||||
|
format!("{}/principal/", self.0)
|
||||||
|
}
|
||||||
fn principal_uri(&self, principal: &str) -> String {
|
fn principal_uri(&self, principal: &str) -> String {
|
||||||
format!("{}/principal/{}/", self.0, principal)
|
format!("{}{}/", self.principal_collection(), principal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,6 +74,11 @@ impl Resource for PrincipalResource {
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
PrincipalPropName::AlternateUriSet => PrincipalProp::AlternateUriSet,
|
PrincipalPropName::AlternateUriSet => PrincipalProp::AlternateUriSet,
|
||||||
|
PrincipalPropName::PrincipalCollectionSet => {
|
||||||
|
PrincipalProp::PrincipalCollectionSet(PrincipalCollectionSet(
|
||||||
|
puri.principal_collection().into(),
|
||||||
|
))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
PrincipalPropWrapperName::Common(prop) => PrincipalPropWrapper::Common(
|
PrincipalPropWrapperName::Common(prop) => PrincipalPropWrapper::Common(
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ pub enum PrincipalProp {
|
|||||||
GroupMembership(GroupMembership),
|
GroupMembership(GroupMembership),
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_DAV", rename = b"alternate-URI-set")]
|
#[xml(ns = "rustical_dav::namespace::NS_DAV", rename = b"alternate-URI-set")]
|
||||||
AlternateUriSet,
|
AlternateUriSet,
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_DAV")]
|
||||||
|
PrincipalCollectionSet(PrincipalCollectionSet),
|
||||||
|
|
||||||
// CalDAV (RFC 4791)
|
// CalDAV (RFC 4791)
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
||||||
@@ -36,3 +38,6 @@ pub struct CalendarHomeSet(#[xml(ty = "untagged", flatten)] pub(super) Vec<HrefE
|
|||||||
|
|
||||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone)]
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone)]
|
||||||
pub struct GroupMembership(#[xml(ty = "untagged", flatten)] pub(super) Vec<HrefElement>);
|
pub struct GroupMembership(#[xml(ty = "untagged", flatten)] pub(super) Vec<HrefElement>);
|
||||||
|
|
||||||
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone)]
|
||||||
|
pub struct PrincipalCollectionSet(#[xml(ty = "untagged")] pub(super) HrefElement);
|
||||||
|
|||||||
@@ -22,8 +22,11 @@ pub mod principal;
|
|||||||
pub struct CardDavPrincipalUri(&'static str);
|
pub struct CardDavPrincipalUri(&'static str);
|
||||||
|
|
||||||
impl PrincipalUri for CardDavPrincipalUri {
|
impl PrincipalUri for CardDavPrincipalUri {
|
||||||
|
fn principal_collection(&self) -> String {
|
||||||
|
format!("{}/principal/", self.0)
|
||||||
|
}
|
||||||
fn principal_uri(&self, principal: &str) -> String {
|
fn principal_uri(&self, principal: &str) -> String {
|
||||||
format!("{}/principal/{}/", self.0, principal)
|
format!("{}{}/", self.principal_collection(), principal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,6 +70,11 @@ impl Resource for PrincipalResource {
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
PrincipalPropName::AlternateUriSet => PrincipalProp::AlternateUriSet,
|
PrincipalPropName::AlternateUriSet => PrincipalProp::AlternateUriSet,
|
||||||
|
PrincipalPropName::PrincipalCollectionSet => {
|
||||||
|
PrincipalProp::PrincipalCollectionSet(PrincipalCollectionSet(
|
||||||
|
puri.principal_collection().into(),
|
||||||
|
))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
use rustical_dav::{extensions::CommonPropertiesProp, xml::HrefElement};
|
use rustical_dav::{extensions::CommonPropertiesProp, xml::HrefElement};
|
||||||
use rustical_xml::{EnumVariants, PropName, XmlDeserialize, XmlSerialize};
|
use rustical_xml::{EnumVariants, PropName, XmlDeserialize, XmlSerialize};
|
||||||
|
|
||||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone)]
|
|
||||||
pub struct AddressbookHomeSet(#[xml(ty = "untagged", flatten)] pub(super) Vec<HrefElement>);
|
|
||||||
|
|
||||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone, EnumVariants, PropName)]
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone, EnumVariants, PropName)]
|
||||||
#[xml(unit_variants_ident = "PrincipalPropName")]
|
#[xml(unit_variants_ident = "PrincipalPropName")]
|
||||||
pub enum PrincipalProp {
|
pub enum PrincipalProp {
|
||||||
@@ -15,6 +12,8 @@ pub enum PrincipalProp {
|
|||||||
GroupMembership(GroupMembership),
|
GroupMembership(GroupMembership),
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_DAV", rename = b"alternate-URI-set")]
|
#[xml(ns = "rustical_dav::namespace::NS_DAV", rename = b"alternate-URI-set")]
|
||||||
AlternateUriSet,
|
AlternateUriSet,
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_DAV")]
|
||||||
|
PrincipalCollectionSet(PrincipalCollectionSet),
|
||||||
|
|
||||||
// CardDAV (RFC 6352)
|
// CardDAV (RFC 6352)
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
||||||
@@ -30,5 +29,11 @@ pub enum PrincipalPropWrapper {
|
|||||||
Common(CommonPropertiesProp),
|
Common(CommonPropertiesProp),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone)]
|
||||||
|
pub struct AddressbookHomeSet(#[xml(ty = "untagged", flatten)] pub(super) Vec<HrefElement>);
|
||||||
|
|
||||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone)]
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone)]
|
||||||
pub struct GroupMembership(#[xml(ty = "untagged", flatten)] pub(super) Vec<HrefElement>);
|
pub struct GroupMembership(#[xml(ty = "untagged", flatten)] pub(super) Vec<HrefElement>);
|
||||||
|
|
||||||
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone)]
|
||||||
|
pub struct PrincipalCollectionSet(#[xml(ty = "untagged")] pub(super) HrefElement);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
pub trait PrincipalUri: 'static + Clone + Send + Sync {
|
pub trait PrincipalUri: 'static + Clone + Send + Sync {
|
||||||
|
fn principal_collection(&self) -> String;
|
||||||
fn principal_uri(&self, principal: &str) -> String;
|
fn principal_uri(&self, principal: &str) -> String;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user