summaryrefslogtreecommitdiff
path: root/src/chunkid.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-10-16 07:49:02 +0300
committerLars Wirzenius <liw@liw.fi>2020-10-16 11:26:04 +0300
commit74751e82695b4b0dbed3466a2caf120a020b4229 (patch)
treeadb80843c262de6066ca9219d14aa43fb3ab08d8 /src/chunkid.rs
parent1b67cf9c535085541d653c6213cd7e7ab5090564 (diff)
downloadobnam2-74751e82695b4b0dbed3466a2caf120a020b4229.tar.gz
feat: obnam-restore restores generation to stdout
Diffstat (limited to 'src/chunkid.rs')
-rw-r--r--src/chunkid.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/chunkid.rs b/src/chunkid.rs
index 44a76d6..e9582b5 100644
--- a/src/chunkid.rs
+++ b/src/chunkid.rs
@@ -1,4 +1,4 @@
-use serde::Serialize;
+use serde::{Deserialize, Serialize};
use std::fmt;
use std::hash::Hash;
use std::str::FromStr;
@@ -19,7 +19,7 @@ use uuid::Uuid;
///
/// Because every identifier is meant to be different, there is no
/// default value, since default values should be identical.
-#[derive(Debug, Eq, PartialEq, Clone, Hash, Serialize)]
+#[derive(Debug, Eq, PartialEq, Clone, Hash, Serialize, Deserialize)]
pub struct ChunkId {
id: String,
}
@@ -43,10 +43,15 @@ impl fmt::Display for ChunkId {
}
}
+impl From<&String> for ChunkId {
+ fn from(s: &String) -> Self {
+ ChunkId { id: s.to_string() }
+ }
+}
+
impl FromStr for ChunkId {
type Err = ();
- /// Parse a string representation of an identifier.
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(ChunkId { id: s.to_string() })
}