1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
use crate::davpath::DavPath;
use std::fmt::Debug;
use std::time::{Duration, SystemTime};
use xmltree::Element;
#[derive(Debug, Clone)]
pub struct DavLock {
pub token: String,
pub path: DavPath,
pub principal: Option<String>,
pub owner: Option<Element>,
pub timeout_at: Option<SystemTime>,
pub timeout: Option<Duration>,
pub shared: bool,
pub deep: bool,
}
pub trait DavLockSystem: Debug + Sync + Send + BoxCloneLs {
fn lock(
&self,
path: &DavPath,
principal: Option<&str>,
owner: Option<&Element>,
timeout: Option<Duration>,
shared: bool,
deep: bool,
) -> Result<DavLock, DavLock>;
fn unlock(&self, path: &DavPath, token: &str) -> Result<(), ()>;
fn refresh(&self, path: &DavPath, token: &str, timeout: Option<Duration>) -> Result<DavLock, ()>;
fn check(
&self,
path: &DavPath,
principal: Option<&str>,
ignore_principal: bool,
deep: bool,
submitted_tokens: Vec<&str>,
) -> Result<(), DavLock>;
fn discover(&self, path: &DavPath) -> Vec<DavLock>;
fn delete(&self, path: &DavPath) -> Result<(), ()>;
}
#[doc(hidden)]
pub trait BoxCloneLs {
fn box_clone(&self) -> Box<dyn DavLockSystem>;
}
impl Clone for Box<dyn DavLockSystem> {
fn clone(&self) -> Box<dyn DavLockSystem> {
self.box_clone()
}
}
#[doc(hidden)]
impl<LS: Clone + DavLockSystem + 'static> BoxCloneLs for LS {
fn box_clone(&self) -> Box<dyn DavLockSystem> {
Box::new((*self).clone())
}
}