Implement helper write_with_parser()
This commit is contained in:
parent
25b26b03a6
commit
c23a1e22ab
1 changed files with 15 additions and 0 deletions
|
@ -253,3 +253,18 @@ impl Display for StorageBackendError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fn write_with_parser<'a, HP>(f: &File, p: &Parser<HP>) -> Result<String, StorageBackendError>
|
||||||
|
where HP: FileHeaderParser
|
||||||
|
{
|
||||||
|
p.write(f.contents())
|
||||||
|
.or_else(|err| {
|
||||||
|
let mut serr = StorageBackendError::build(
|
||||||
|
"Parser::write()",
|
||||||
|
"Cannot translate internal representation of file contents into on-disk representation",
|
||||||
|
None
|
||||||
|
);
|
||||||
|
serr.caused_by = Some(Box::new(err));
|
||||||
|
Err(serr)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue