carddav calendar-query: Add parsing support for limit

This commit is contained in:
Lennart
2025-12-31 15:15:07 +01:00
parent 037e6f5c92
commit 829f7b727f
2 changed files with 35 additions and 3 deletions

View File

@@ -105,4 +105,30 @@ pub struct AddressbookQueryRequest {
pub prop: PropfindType<AddressObjectPropWrapperName>,
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
pub(crate) filter: FilterElement,
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
pub(crate) limit: Option<LimitElement>,
}
// https://datatracker.ietf.org/doc/html/rfc5323#section-5.17
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq)]
pub struct LimitElement {
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
pub nresults: NresultsElement,
}
impl From<u64> for LimitElement {
fn from(value: u64) -> Self {
Self {
nresults: NresultsElement(value),
}
}
}
impl From<LimitElement> for u64 {
fn from(value: LimitElement) -> Self {
value.nresults.0
}
}
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq)]
pub struct NresultsElement(#[xml(ty = "text")] pub u64);

View File

@@ -159,7 +159,7 @@ mod tests {
use crate::{
address_object::AddressObjectPropName,
addressbook::methods::report::addressbook_query::{
Allof, FilterElement, PropFilterElement,
Allof, FilterElement, LimitElement, NresultsElement, PropFilterElement,
},
};
use rustical_dav::xml::{PropElement, sync_collection::SyncLevel};
@@ -237,6 +237,9 @@ mod tests {
<card:filter>
<card:prop-filter name="FN"/>
</card:filter>
<card:limit>
<card:nresults>100</card:nresults>
</card:limit>
</card:addressbook-query>
"#,
)
@@ -259,8 +262,11 @@ mod tests {
text_match: vec![],
param_filter: vec![],
test: Allof::default()
}]
}
}],
},
limit: Some(LimitElement {
nresults: NresultsElement(100)
})
})
);
}