summaryrefslogtreecommitdiff
path: root/src/chunkid.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-01-03 13:09:35 +0200
committerLars Wirzenius <liw@liw.fi>2021-01-03 13:53:43 +0200
commit543107a70eeffaa6932c87c02b43b0fd4f8558e5 (patch)
tree2cfb0b9e4dd69f93413d0e934e1113534d7352dc /src/chunkid.rs
parente6a4eb6edf83a68a6f73094126804beb0c569937 (diff)
downloadobnam2-543107a70eeffaa6932c87c02b43b0fd4f8558e5.tar.gz
feat: load chunk metadata into index at startup
This needs to be replace with a database or something, but it'll do for now.
Diffstat (limited to 'src/chunkid.rs')
-rw-r--r--src/chunkid.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/chunkid.rs b/src/chunkid.rs
index 73e0b27..9eec41f 100644
--- a/src/chunkid.rs
+++ b/src/chunkid.rs
@@ -2,6 +2,7 @@ use crate::checksummer::sha256;
use rusqlite::types::ToSqlOutput;
use rusqlite::ToSql;
use serde::{Deserialize, Serialize};
+use std::ffi::OsStr;
use std::fmt;
use std::hash::Hash;
use std::str::FromStr;
@@ -68,6 +69,14 @@ impl From<&String> for ChunkId {
}
}
+impl From<&OsStr> for ChunkId {
+ fn from(s: &OsStr) -> Self {
+ ChunkId {
+ id: s.to_string_lossy().to_string(),
+ }
+ }
+}
+
impl FromStr for ChunkId {
type Err = ();