src/backup/manifest.rs: impl TryFrom DataBlob

This commit is contained in:
Dietmar Maurer 2020-01-05 16:20:26 +01:00
parent 7759eef552
commit 247a8ca5bb

View File

@ -100,6 +100,17 @@ impl BackupManifest {
}
}
impl TryFrom<super::DataBlob> for BackupManifest {
type Error = Error;
fn try_from(blob: super::DataBlob) -> Result<Self, Error> {
let data = blob.decode(None)
.map_err(|err| format_err!("decode backup manifest blob failed - {}", err))?;
let json: Value = serde_json::from_slice(&data[..])
.map_err(|err| format_err!("unable to parse backup manifest json - {}", err))?;
BackupManifest::try_from(json)
}
}
impl TryFrom<Value> for BackupManifest {
type Error = Error;