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
use std::error::Error;
use std::fs;
use std::path::Path;
use append::rolling_file::policy::compound::roll::Roll;
#[cfg(feature = "file")]
use file::{Deserialize, Deserializers};
#[cfg(feature = "file")]
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
pub struct DeleteRollerConfig {
#[serde(skip_deserializing)] _p: (),
}
#[derive(Debug)]
pub struct DeleteRoller(());
impl Roll for DeleteRoller {
fn roll(&self, file: &Path) -> Result<(), Box<Error + Sync + Send>> {
fs::remove_file(file).map_err(Into::into)
}
}
impl DeleteRoller {
pub fn new() -> DeleteRoller {
DeleteRoller(())
}
}
#[cfg(feature = "file")]
pub struct DeleteRollerDeserializer;
#[cfg(feature = "file")]
impl Deserialize for DeleteRollerDeserializer {
type Trait = Roll;
type Config = DeleteRollerConfig;
fn deserialize(
&self,
_: DeleteRollerConfig,
_: &Deserializers,
) -> Result<Box<Roll>, Box<Error + Sync + Send>> {
Ok(Box::new(DeleteRoller::new()))
}
}