blob: b13d4a7df60a0c8ea032bb6bb61cc9a18b624fe8 (
plain)
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
|
use std::{
path::PathBuf,
time::{Duration, SystemTime},
};
pub use self::error::Error;
pub use self::git::GitProject;
pub use self::path::PathProject;
mod error;
mod git;
mod path;
pub trait Timestamp {
type Error;
fn timestamp(&self) -> Result<Duration, Self::Error>;
}
impl<T> Timestamp for T
where
T: AsRef<PathBuf>,
{
type Error = Error;
fn timestamp(&self) -> Result<Duration, Self::Error> {
self.as_ref()
.metadata()?
.modified()?
.duration_since(SystemTime::UNIX_EPOCH)
.map_err(Into::into)
}
}
pub trait Project: Timestamp {
fn to_path_buf(&self) -> &PathBuf;
}
impl<T> Project for T
where
T: Timestamp,
T: AsRef<PathBuf>,
{
fn to_path_buf(&self) -> &PathBuf {
self.as_ref()
}
}
|