dav_server/dav_filters.rs
1//! Common filter types shared between CalDAV and CardDAV
2//!
3//! This module contains filter structures used by both CalDAV (RFC 4791)
4//! and CardDAV (RFC 6352) REPORT requests.
5
6/// Text matching filter for property values
7///
8/// Used in both CalDAV and CardDAV for matching text content in properties.
9#[derive(Debug, Clone, Default)]
10pub struct TextMatch {
11 /// The text to match against
12 pub text: String,
13 /// Collation to use for comparison (e.g., "i;ascii-casemap")
14 pub collation: Option<String>,
15 /// If true, the match condition is negated
16 pub negate_condition: bool,
17 /// Match type for CardDAV: "equals", "contains", "starts-with", "ends-with"
18 /// CalDAV uses "contains" by default if not specified
19 pub match_type: Option<String>,
20}
21
22/// Parameter filter for matching property parameters
23///
24/// Used in both CalDAV and CardDAV for filtering based on property parameters
25/// (e.g., TYPE=HOME on a TEL property).
26#[derive(Debug, Clone)]
27pub struct ParameterFilter {
28 /// Name of the parameter to filter on (e.g., "TYPE")
29 pub name: String,
30 /// If true, the parameter must NOT be defined
31 pub is_not_defined: bool,
32 /// Text match filter for the parameter value
33 pub text_match: Option<TextMatch>,
34}
35
36impl ParameterFilter {
37 /// Create a new parameter filter with the given name
38 pub fn new(name: impl Into<String>) -> Self {
39 Self {
40 name: name.into(),
41 is_not_defined: false,
42 text_match: None,
43 }
44 }
45}