M libdav/src/dav.rs => libdav/src/dav.rs +2 -0
@@ 298,6 298,8 @@ where
/// Fetch multiple properties for a single resource.
///
+ /// Values in the returned `Vec` are in the same order as the `properties` parameter.
+ ///
/// # Quirks
///
/// Same as [`WebDavClient::get_property`].
M vstorage/src/caldav.rs => vstorage/src/caldav.rs +18 -10
@@ 369,18 369,26 @@ where
&self,
collection_href: &str,
) -> Result<Vec<ListedProperty<CalendarProperty>>> {
- let mut props = Vec::new();
- for property in CalendarProperty::known_properties() {
- let prop_value = self.get_property(collection_href, property.clone()).await?;
- if let Some(value) = prop_value {
- props.push(ListedProperty {
+ let prop_names = CalendarProperty::known_properties()
+ .iter()
+ .map(|p| p.dav_propname())
+ .collect::<Vec<_>>();
+ let result = self
+ .client
+ .get_properties(collection_href, &prop_names)
+ .await?
+ .into_iter()
+ .zip(CalendarProperty::known_properties())
+ .filter_map(|((_, v), p)| {
+ v.map(|value| ListedProperty {
resource: PropertyTarget::Collection(collection_href.to_owned()),
- property: property.clone(),
+ property: p.clone(),
value,
- });
- };
- }
- return Ok(props);
+ })
+ })
+ .collect::<Vec<_>>();
+
+ return Ok(result);
}
}
M vstorage/src/carddav.rs => vstorage/src/carddav.rs +18 -10
@@ 357,18 357,26 @@ where
&self,
collection_href: &str,
) -> Result<Vec<ListedProperty<AddressBookProperty>>> {
- let mut props = Vec::new();
- for property in AddressBookProperty::known_properties() {
- let prop_value = self.get_property(collection_href, property.clone()).await?;
- if let Some(value) = prop_value {
- props.push(ListedProperty {
+ let prop_names = AddressBookProperty::known_properties()
+ .iter()
+ .map(|p| p.dav_propname())
+ .collect::<Vec<_>>();
+ let result = self
+ .client
+ .get_properties(collection_href, &prop_names)
+ .await?
+ .into_iter()
+ .zip(AddressBookProperty::known_properties())
+ .filter_map(|((_, v), p)| {
+ v.map(|value| ListedProperty {
resource: PropertyTarget::Collection(collection_href.to_owned()),
- property: property.clone(),
+ property: p.clone(),
value,
- });
- };
- }
- return Ok(props);
+ })
+ })
+ .collect::<Vec<_>>();
+
+ return Ok(result);
}
}