cobble_core/minecraft/screenshots/
screenshot.rs1use crate::error::CobbleResult;
2use std::path::PathBuf;
3use time::OffsetDateTime;
4use tokio::fs::remove_file;
5
6#[cfg_attr(doc_cfg, doc(cfg(feature = "screenshots")))]
8#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
9#[derive(Clone, Debug)]
10pub struct Screenshot {
11 pub name: String,
13 pub path: PathBuf,
15 #[cfg_attr(feature = "serde", serde(with = "time::serde::rfc3339::option"))]
17 pub created: Option<OffsetDateTime>,
18}
19
20impl Screenshot {
21 #[instrument(
25 name = "remove_screenshot",
26 level = "trace",
27 skip_all,
28 fields(
29 name,
30 path = %self.path.to_string_lossy(),
31 )
32 )]
33 pub async fn remove(self) -> CobbleResult<()> {
34 remove_file(&self.path).await?;
35 Ok(())
36 }
37}