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
use crate::RecycleOpt;
impl RecycleOpt {
pub fn debug(&self) -> bool {
match self {
RecycleOpt::List(copt) => copt.debug,
RecycleOpt::Get(nopt) => nopt.copt.debug,
RecycleOpt::Revive(nopt) => nopt.copt.debug,
}
}
pub fn exec(&self) {
match self {
RecycleOpt::List(copt) => {
let client = copt.to_client();
match client.recycle_bin_list() {
Ok(r) => r.iter().for_each(|e| println!("{}", e)),
Err(e) => {
error!("Error -> {:?}", e);
}
}
}
RecycleOpt::Get(nopt) => {
let client = nopt.copt.to_client();
match client.recycle_bin_get(nopt.name.as_str()) {
Ok(Some(e)) => println!("{}", e),
Ok(None) => println!("No matching entries"),
Err(e) => {
error!("Error -> {:?}", e);
}
}
}
RecycleOpt::Revive(nopt) => {
let client = nopt.copt.to_client();
if let Err(e) = client.recycle_bin_revive(nopt.name.as_str()) {
error!("Error -> {:?}", e);
}
}
}
}
}