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
use std::path::PathBuf;
#[derive(Debug, Clone, PartialEq)]
pub struct RetryConf {
max: u64,
multiplier: f64,
store_file_path: Option<PathBuf>,
}
impl Default for RetryConf {
fn default() -> RetryConf {
RetryConf {
max: 10,
multiplier: 5_f64,
store_file_path: None,
}
}
}
impl RetryConf {
pub fn new() -> RetryConf {
Default::default()
}
pub fn max(mut self, max: u64) -> RetryConf {
self.max = max;
self
}
pub fn multiplier(mut self, multiplier: f64) -> RetryConf {
self.multiplier = multiplier;
self
}
pub fn store_file(mut self, path: PathBuf) -> RetryConf {
self.store_file_path = Some(path);
self
}
pub fn need_to_store(self) -> bool {
self.store_file_path.is_some()
}
pub fn store_path(self) -> Option<PathBuf> {
self.store_file_path
}
pub fn build(self) -> (u64, f64) {
(self.max, self.multiplier)
}
}