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
use std::time::Duration;
#[derive(Clone, Debug)]
pub struct Policy {
max_capacity: Option<u64>,
num_segments: usize,
time_to_live: Option<Duration>,
time_to_idle: Option<Duration>,
}
impl Policy {
pub(crate) fn new(
max_capacity: Option<u64>,
num_segments: usize,
time_to_live: Option<Duration>,
time_to_idle: Option<Duration>,
) -> Self {
Self {
max_capacity,
num_segments,
time_to_live,
time_to_idle,
}
}
pub fn max_capacity(&self) -> Option<u64> {
self.max_capacity
}
pub(crate) fn set_max_capacity(&mut self, capacity: Option<u64>) {
self.max_capacity = capacity;
}
pub fn num_segments(&self) -> usize {
self.num_segments
}
pub(crate) fn set_num_segments(&mut self, num: usize) {
self.num_segments = num;
}
pub fn time_to_live(&self) -> Option<Duration> {
self.time_to_live
}
pub fn time_to_idle(&self) -> Option<Duration> {
self.time_to_idle
}
}