Add proper impl of Store::reset_backend()

This commit is contained in:
Matthias Beyer 2017-06-18 18:48:08 +02:00
parent c814171875
commit a4188a3100

View file

@ -320,9 +320,11 @@ impl Store {
/// Currently, this is the naive implementatoin which does not transfer contents of the
/// backends.
///
pub fn reset_backend(&mut self, backend: Box<FileAbstraction>) -> Result<()> {
self.backend = backend;
Ok(())
pub fn reset_backend(&mut self, mut backend: Box<FileAbstraction>) -> Result<()> {
self.backend
.drain()
.and_then(|drain| backend.fill(drain))
.map(|_| self.backend = backend)
}
/// Get the store configuration