diff --git a/Cargo.lock b/Cargo.lock index 70c5066..d0fd08b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3390,6 +3390,7 @@ dependencies = [ "futures-util", "headers", "http", + "ical", "itertools 0.14.0", "log", "matchit 0.9.0", diff --git a/Cargo.toml b/Cargo.toml index d53984e..1585f1e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ opentelemetry = [ debug = 0 [workspace.dependencies] -rustical_dav = { path = "./crates/dav/" } +rustical_dav = { path = "./crates/dav/", features = ["ical"] } rustical_dav_push = { path = "./crates/dav_push/" } rustical_store = { path = "./crates/store/" } rustical_store_sqlite = { path = "./crates/store_sqlite/" } diff --git a/crates/caldav/Cargo.toml b/crates/caldav/Cargo.toml index ac3a37b..cde976d 100644 --- a/crates/caldav/Cargo.toml +++ b/crates/caldav/Cargo.toml @@ -29,7 +29,7 @@ base64.workspace = true serde.workspace = true tokio.workspace = true url.workspace = true -rustical_dav.workspace = true +rustical_dav = { workspace = true, features = ["ical"] } rustical_store.workspace = true chrono.workspace = true chrono-tz.workspace = true diff --git a/crates/caldav/src/calendar/methods/report/calendar_query/comp_filter.rs b/crates/caldav/src/calendar/methods/report/calendar_query/comp_filter.rs index ada5286..dc0e2e5 100644 --- a/crates/caldav/src/calendar/methods/report/calendar_query/comp_filter.rs +++ b/crates/caldav/src/calendar/methods/report/calendar_query/comp_filter.rs @@ -137,13 +137,11 @@ impl CompFilterable for CalendarObjectComponent { #[cfg(test)] mod tests { use chrono::{TimeZone, Utc}; + use rustical_dav::xml::{NegateCondition, TextCollation, TextMatchElement}; use rustical_ical::{CalendarObject, UtcDateTime}; use crate::calendar::methods::report::calendar_query::{ - CompFilterable, TextMatchElement, TimeRangeElement, - comp_filter::CompFilterElement, - prop_filter::PropFilterElement, - text_match::{NegateCondition, TextCollation}, + CompFilterElement, CompFilterable, PropFilterElement, TimeRangeElement, }; const ICS: &str = r"BEGIN:VCALENDAR diff --git a/crates/caldav/src/calendar/methods/report/calendar_query/elements.rs b/crates/caldav/src/calendar/methods/report/calendar_query/elements.rs index 0f78b81..d569e6d 100644 --- a/crates/caldav/src/calendar/methods/report/calendar_query/elements.rs +++ b/crates/caldav/src/calendar/methods/report/calendar_query/elements.rs @@ -1,11 +1,6 @@ -use crate::{ - calendar::methods::report::calendar_query::{ - TextMatchElement, - comp_filter::{CompFilterElement, CompFilterable}, - }, - calendar_object::CalendarObjectPropWrapperName, -}; -use rustical_dav::xml::PropfindType; +use super::comp_filter::{CompFilterElement, CompFilterable}; +use crate::calendar_object::CalendarObjectPropWrapperName; +use rustical_dav::xml::{PropfindType, TextMatchElement}; use rustical_ical::{CalendarObject, UtcDateTime}; use rustical_store::calendar_store::CalendarQuery; use rustical_xml::XmlDeserialize; diff --git a/crates/caldav/src/calendar/methods/report/calendar_query/mod.rs b/crates/caldav/src/calendar/methods/report/calendar_query/mod.rs index 9e12a3f..6e23e78 100644 --- a/crates/caldav/src/calendar/methods/report/calendar_query/mod.rs +++ b/crates/caldav/src/calendar/methods/report/calendar_query/mod.rs @@ -5,14 +5,11 @@ use rustical_store::CalendarStore; mod comp_filter; mod elements; mod prop_filter; -pub mod text_match; #[allow(unused_imports)] pub use comp_filter::{CompFilterElement, CompFilterable}; pub use elements::*; #[allow(unused_imports)] pub use prop_filter::{PropFilterElement, PropFilterable}; -#[allow(unused_imports)] -pub use text_match::TextMatchElement; pub async fn get_objects_calendar_query( cal_query: &CalendarQueryRequest, @@ -31,21 +28,16 @@ pub async fn get_objects_calendar_query( #[cfg(test)] mod tests { - use rustical_dav::xml::PropElement; - use rustical_xml::XmlDocument; - + use super::{ + CalendarQueryRequest, FilterElement, ParamFilterElement, comp_filter::CompFilterElement, + prop_filter::PropFilterElement, + }; use crate::{ - calendar::methods::report::{ - ReportRequest, - calendar_query::{ - CalendarQueryRequest, FilterElement, ParamFilterElement, TextMatchElement, - comp_filter::CompFilterElement, - prop_filter::PropFilterElement, - text_match::{NegateCondition, TextCollation}, - }, - }, + calendar::methods::report::ReportRequest, calendar_object::{CalendarData, CalendarObjectPropName, CalendarObjectPropWrapperName}, }; + use rustical_dav::xml::{NegateCondition, PropElement, TextCollation, TextMatchElement}; + use rustical_xml::XmlDocument; #[test] fn calendar_query_7_8_7() { diff --git a/crates/caldav/src/calendar/methods/report/calendar_query/prop_filter.rs b/crates/caldav/src/calendar/methods/report/calendar_query/prop_filter.rs index 9da7480..a4ae647 100644 --- a/crates/caldav/src/calendar/methods/report/calendar_query/prop_filter.rs +++ b/crates/caldav/src/calendar/methods/report/calendar_query/prop_filter.rs @@ -1,5 +1,4 @@ -use std::collections::HashMap; - +use super::{ParamFilterElement, TimeRangeElement}; use ical::{ generator::{IcalCalendar, IcalEvent}, parser::{ @@ -8,12 +7,10 @@ use ical::{ }, property::Property, }; +use rustical_dav::xml::TextMatchElement; use rustical_ical::{CalDateTime, CalendarObject, CalendarObjectComponent, UtcDateTime}; use rustical_xml::XmlDeserialize; - -use crate::calendar::methods::report::calendar_query::{ - ParamFilterElement, TextMatchElement, TimeRangeElement, -}; +use std::collections::HashMap; #[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq)] #[allow(dead_code)] diff --git a/crates/caldav/src/calendar/prop.rs b/crates/caldav/src/calendar/prop.rs index cf3a0a7..efe3085 100644 --- a/crates/caldav/src/calendar/prop.rs +++ b/crates/caldav/src/calendar/prop.rs @@ -1,10 +1,9 @@ use derive_more::derive::{From, Into}; +use rustical_dav::xml::TextCollation; use rustical_ical::CalendarObjectType; use rustical_xml::{XmlDeserialize, XmlSerialize}; use strum_macros::VariantArray; -use crate::calendar::methods::report::calendar_query::text_match::TextCollation; - #[derive(Debug, Clone, XmlSerialize, XmlDeserialize, PartialEq, Eq, From, Into)] pub struct SupportedCalendarComponent { #[xml(ty = "attr")] diff --git a/crates/dav/Cargo.toml b/crates/dav/Cargo.toml index e54df5b..3cbab40 100644 --- a/crates/dav/Cargo.toml +++ b/crates/dav/Cargo.toml @@ -28,3 +28,7 @@ headers.workspace = true strum.workspace = true matchit.workspace = true matchit-serde.workspace = true +ical = { workspace = true, optional = true } + +[features] +ical = ["dep:ical"] diff --git a/crates/dav/src/xml/mod.rs b/crates/dav/src/xml/mod.rs index beac1f5..c09a60e 100644 --- a/crates/dav/src/xml/mod.rs +++ b/crates/dav/src/xml/mod.rs @@ -15,3 +15,7 @@ mod report_set; pub use report_set::SupportedReportSet; mod group; pub use group::*; +#[cfg(feature = "ical")] +mod text_match; +#[cfg(feature = "ical")] +pub use text_match::*; diff --git a/crates/caldav/src/calendar/methods/report/calendar_query/text_match.rs b/crates/dav/src/xml/text_match.rs similarity index 94% rename from crates/caldav/src/calendar/methods/report/calendar_query/text_match.rs rename to crates/dav/src/xml/text_match.rs index 9d8af6f..b79c634 100644 --- a/crates/caldav/src/calendar/methods/report/calendar_query/text_match.rs +++ b/crates/dav/src/xml/text_match.rs @@ -64,9 +64,9 @@ pub struct TextMatchElement { #[xml(ty = "attr", default = "Default::default")] pub collation: TextCollation, #[xml(ty = "attr", default = "Default::default")] - pub(crate) negate_condition: NegateCondition, + pub negate_condition: NegateCondition, #[xml(ty = "text")] - pub(crate) needle: String, + pub needle: String, } impl TextMatchElement { @@ -90,7 +90,7 @@ impl TextMatchElement { #[cfg(test)] mod tests { - use crate::calendar::methods::report::calendar_query::text_match::TextCollation; + use super::TextCollation; #[test] fn test_collation() {