use crate::error::CobbleResult;
use std::path::PathBuf;
use time::OffsetDateTime;
use tokio::fs::remove_file;
#[cfg_attr(doc_cfg, doc(cfg(feature = "screenshots")))]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[derive(Clone, Debug)]
pub struct Screenshot {
pub name: String,
pub path: PathBuf,
#[cfg_attr(feature = "serde", serde(with = "time::serde::rfc3339::option"))]
pub created: Option<OffsetDateTime>,
}
impl Screenshot {
#[instrument(
name = "remove_screenshot",
level = "trace",
skip_all,
fields(
name,
path = %self.path.to_string_lossy(),
)
)]
pub async fn remove(self) -> CobbleResult<()> {
remove_file(&self.path).await?;
Ok(())
}
}