changepacks_core/
package.rs1use std::path::Path;
2
3use crate::{Language, update_type::UpdateType};
4use anyhow::{Context, Result};
5use async_trait::async_trait;
6
7#[async_trait]
8pub trait Package: std::fmt::Debug + Send + Sync {
9 fn name(&self) -> &str;
10 fn version(&self) -> &str;
11 fn path(&self) -> &Path;
12 fn relative_path(&self) -> &Path;
13 async fn update_version(&self, update_type: UpdateType) -> Result<()>;
14 fn check_changed(&mut self, path: &Path) -> Result<()> {
15 if self.is_changed() {
16 return Ok(());
17 }
18 if !path.to_string_lossy().contains(".changepacks")
19 && path.starts_with(self.path().parent().context("Parent not found")?)
20 {
21 self.set_changed(true);
22 }
23 Ok(())
24 }
25 fn is_changed(&self) -> bool;
26 fn language(&self) -> Language;
27 fn set_changed(&mut self, changed: bool);
28}