From: Olaf Wintermann Date: Fri, 17 Jul 2026 19:19:11 +0000 (+0200) Subject: add first code for dav query API X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fmain;p=note.git add first code for dav query API --- diff --git a/dav-rs/src/dav/mod.rs b/dav-rs/src/dav/mod.rs index 850633b..b60f6ca 100644 --- a/dav-rs/src/dav/mod.rs +++ b/dav-rs/src/dav/mod.rs @@ -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 index 0000000..6249440 --- /dev/null +++ b/dav-rs/src/dav/query.rs @@ -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, + pub filter: Vec, + 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