From 74751e82695b4b0dbed3466a2caf120a020b4229 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 16 Oct 2020 07:49:02 +0300 Subject: feat: obnam-restore restores generation to stdout --- src/chunkid.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/chunkid.rs') 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 { Ok(ChunkId { id: s.to_string() }) } -- cgit v1.2.1