diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-12-31 09:00:21 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-12-31 12:10:10 +0200 |
commit | acf1ba3f8f1492b961c9a6eb09eb93e882f5eb3f (patch) | |
tree | 1ce0288f878cac71990bb01f358d6035f1626c92 /src/backup_reason.rs | |
parent | 686e87981db210fa443404c8473dfe7a3f39b241 (diff) | |
download | obnam2-acf1ba3f8f1492b961c9a6eb09eb93e882f5eb3f.tar.gz |
docs: add documentation comments to crate
Also, make it an error for a public symbol to not be documented.
Sponsored-by: author
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", |