diff options
Diffstat (limited to 'src/backup_reason.rs')
-rw-r--r-- | src/backup_reason.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/backup_reason.rs b/src/backup_reason.rs index 0a51556..590f470 100644 --- a/src/backup_reason.rs +++ b/src/backup_reason.rs @@ -1,19 +1,38 @@ +//! Why was a file backed up? + use rusqlite::types::ToSqlOutput; use rusqlite::ToSql; use std::fmt; +/// Represent the reason a file is in a backup. #[derive(Debug, Copy, Clone)] pub enum Reason { + /// File was skipped for some reason, but carried over without changes. Skipped, + /// File is new, compared to previous backup. IsNew, + /// File has been changed, compared to previous backup, Changed, + /// File has not been changed, compared to previous backup, Unchanged, + /// There was an error looking up the file in the previous backup. + /// + /// File has been carried over without changes. GenerationLookupError, + /// The was an error backing up the file. + /// + /// File has been carried over without changes. FileError, + /// Reason is unknown. + /// + /// The previous backup had a reason that the current version of + /// Obnam doesn't recognize. The file has been carried over + /// without changes. Unknown, } impl Reason { + /// Create a Reason from a string representation. pub fn from(text: &str) -> Reason { match text { "skipped" => Reason::Skipped, @@ -28,6 +47,7 @@ impl Reason { } impl ToSql for Reason { + /// Represent Reason as text for SQL. fn to_sql(&self) -> rusqlite::Result<ToSqlOutput> { Ok(ToSqlOutput::Owned(rusqlite::types::Value::Text(format!( "{}", @@ -37,6 +57,7 @@ impl ToSql for Reason { } impl fmt::Display for Reason { + /// Represent Reason for display. fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let reason = match self { Reason::Skipped => "skipped", |