1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3
4#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
6pub struct Usages {
7 usages: Vec<DateTime<Utc>>,
9}
10
11impl Usages {
12 pub fn clear(&mut self) {
14 self.usages.clear();
15 }
16
17 pub fn list(&self) -> &Vec<DateTime<Utc>> {
19 &self.usages
20 }
21
22 pub fn new() -> Self {
24 Self { usages: Vec::new() }
25 }
26
27 pub fn prune(&mut self, before: DateTime<Utc>) {
29 self.usages.retain(|u| u >= &before);
30 }
31
32 pub fn record_usage(&mut self) {
34 self.usages.push(Utc::now());
35 }
36}