src/backup/datastore.rs: protect BackupGroup fields, impl new()

This commit is contained in:
Dietmar Maurer
2019-03-04 13:38:23 +01:00
parent cdebd467e6
commit 1e9a94e579
4 changed files with 30 additions and 36 deletions

View File

@ -31,13 +31,25 @@ pub struct DataStore {
#[derive(Debug)]
pub struct BackupGroup {
/// Type of backup
pub backup_type: String,
backup_type: String,
/// Unique (for this type) ID
pub backup_id: String,
backup_id: String,
}
impl BackupGroup {
pub fn new<T: Into<String>>(backup_type: T, backup_id: T) -> Self {
Self { backup_type: backup_type.into(), backup_id: backup_id.into() }
}
pub fn backup_type(&self) -> &str {
&self.backup_type
}
pub fn backup_id(&self) -> &str {
&self.backup_id
}
pub fn parse(path: &str) -> Result<Self, Error> {
let cap = GROUP_PATH_REGEX.captures(path)