use anyhow::Context;
use std::ops::Deref;
use std::path::PathBuf;
use std::time::SystemTime;
#[derive(Debug, derive_more::From, derive_more::Into)]
pub struct Metadata {
md: std::fs::Metadata,
path: PathBuf,
}
impl Metadata {
pub fn modified(&self) -> anyhow::Result<SystemTime> {
self.md
.modified()
.with_context(|| format!("while processing path {:?}", self.path.display()))
}
pub fn accessed(&self) -> anyhow::Result<SystemTime> {
self.md
.accessed()
.with_context(|| format!("while processing path {:?}", self.path.display()))
}
pub fn created(&self) -> anyhow::Result<SystemTime> {
self.md
.created()
.with_context(|| format!("while processing path {:?}", self.path.display()))
}
}
impl Deref for Metadata {
type Target = std::fs::Metadata;
fn deref(&self) -> &Self::Target {
&self.md
}
}