use std::time::{SystemTime, UNIX_EPOCH}; use serde::{Deserialize, Serialize}; use uuid::Uuid; use crate::{config::Config, pathinfo::PathInfo, packages::Package, error::Result}; pub type BackupId = String; #[derive(Debug, Serialize, Deserialize)] pub struct Backup { id: String, timestamp: u64, packages: Vec, files: Vec, } impl Backup { pub fn create(config: &Config, packages: Vec) -> Result { let mut files: Vec = Vec::new(); for dir in &config.directories { files.push(PathInfo::from_path(config, dir)?); } Ok(Self { // UUID not really needed, maybe a shorter hash id: Uuid::new_v4().to_string(), timestamp: SystemTime::now() .duration_since(UNIX_EPOCH) .unwrap() .as_secs(), packages, files, }) } } struct BackupLocation { id: BackupId, rel_location: String, } type BackupList = Vec;