cobble_core/minecraft/shaderpacks/
shaderpack.rs

1use crate::error::CobbleResult;
2use std::path::PathBuf;
3use tokio::fs::remove_file;
4
5/// Represents a single shaderpack.
6#[cfg_attr(doc_cfg, doc(cfg(feature = "shaderpacks")))]
7#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
8#[derive(Clone, Debug)]
9pub struct Shaderpack {
10    /// Filename
11    pub name: String,
12    /// Filepath
13    pub path: PathBuf,
14}
15
16impl Shaderpack {
17    /// Removes the shaderpack from disk.
18    ///
19    /// **Warning**: This will permanently delete the file!
20    #[instrument(
21        name = "remove_shaderpack",
22        level = "trace",
23        skip_all,
24        fields(
25            name,
26            path = %self.path.to_string_lossy(),
27        )
28    )]
29    pub async fn remove(self) -> CobbleResult<()> {
30        remove_file(&self.path).await?;
31        Ok(())
32    }
33}