]> uap-core.de Git - note.git/commitdiff
add first code for dav query API main
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Fri, 17 Jul 2026 19:19:11 +0000 (21:19 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Fri, 17 Jul 2026 19:19:11 +0000 (21:19 +0200)
dav-rs/src/dav/mod.rs
dav-rs/src/dav/query.rs [new file with mode: 0644]

index 850633bf9d35397a4d68a1f1d9120a1598a87ae3..b60f6cad1430732c7fcbfab87074b4bdf62d8ae8 100644 (file)
@@ -31,4 +31,5 @@ mod ffi;
 mod session;
 mod resource;
 mod xml;
-mod utils;
\ No newline at end of file
+mod utils;
+mod query;
diff --git a/dav-rs/src/dav/query.rs b/dav-rs/src/dav/query.rs
new file mode 100644 (file)
index 0000000..6249440
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2026 Olaf Wintermann. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *   1. Redistributions of source code must retain the above copyright
+ *      notice, this list of conditions and the following disclaimer.
+ *
+ *   2. Redistributions in binary form must reproduce the above copyright
+ *      notice, this list of conditions and the following disclaimer in the
+ *      documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#![allow(dead_code)]
+
+use crate::dav::session::Session;
+
+pub struct DavQuery {
+    pub from: String,
+    pub properties: Vec<String>,
+    pub filter: Vec<String>,
+    pub depth: u16
+}
+
+pub fn query(from: &str) -> DavQuery {
+    DavQuery {
+        from: from.to_string(),
+        properties: Vec::new(),
+        filter: Vec::new(),
+        depth: 1
+    }
+}
+
+impl DavQuery {
+    pub fn property(&mut self, prop: &str) -> &Self {
+        self.properties.push(prop.to_string());
+        self
+    }
+
+    pub fn depth(&mut self, depth: u16) -> &mut Self {
+        self.depth = depth;
+        self
+    }
+
+    pub fn filter(&mut self, filter: Cmp) -> &mut Self {
+        self.filter.push(filter.cmp);
+        self
+    }
+}
+
+
+pub struct Cmp {
+    cmp: String,
+}
+
+
+impl Cmp {
+    pub fn eq_str(prop: &str, str: &str) -> Cmp {
+        Cmp {
+            cmp: format!("{} = '{}'", prop, str),
+        }
+    }
+}
\ No newline at end of file