libkelp/lib/structs/
fileinfo.rs

1pub use serde::{Deserialize, Serialize};
2#[derive(PartialEq, Serialize, Deserialize, Debug, Clone)]
3/// FileINFO struct: used for represent a file to backup
4pub struct FileInfo {
5    /// The name of the file, optional but recommended to reconize files
6    pub name: Option<String>,
7    /// The path to the file "relative to / or /home/$USER"
8    pub path: String,
9    /// Is the file backup only ? Or must it be reinstalled
10    pub backuponly: Option<bool>,
11    /// If the file is only usable on specific disto, specify it
12    /// Note: There's a list of bundled OSes
13    pub onlyon: Option<String>,
14}
15// If the file is named, print it's name
16// Else print it's path
17impl std::fmt::Display for FileInfo {
18    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
19        if let Some(n) = &self.name {
20            write!(f, "{}", n)
21        } else {
22            write!(f, "{}", self.path)
23        }
24    }
25}