diff options
author | Lars Wirzenius <liw@liw.fi> | 2020-11-08 12:15:23 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2020-11-08 18:50:23 +0200 |
commit | ec07ffe546300ca594a95851e8828987d68e4841 (patch) | |
tree | f24ae7932862eba35ed08ca39e8efe3e56745f8a /src | |
parent | bb013c2364569f224dd55f549c554a358aee666f (diff) | |
download | obnam2-ec07ffe546300ca594a95851e8828987d68e4841.tar.gz |
feat: make ChunkId serializable to SQLite
We will need this when we store a backup generation in an SQLite file.
Diffstat (limited to 'src')
-rw-r--r-- | src/chunkid.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/chunkid.rs b/src/chunkid.rs index e9582b5..781e497 100644 --- a/src/chunkid.rs +++ b/src/chunkid.rs @@ -1,3 +1,5 @@ +use rusqlite::types::ToSqlOutput; +use rusqlite::ToSql; use serde::{Deserialize, Serialize}; use std::fmt; use std::hash::Hash; @@ -34,6 +36,14 @@ impl ChunkId { } } +impl ToSql for ChunkId { + fn to_sql(&self) -> rusqlite::Result<ToSqlOutput> { + Ok(ToSqlOutput::Owned(rusqlite::types::Value::Text( + self.id.clone(), + ))) + } +} + impl fmt::Display for ChunkId { /// Format an identifier for display. /// |