Backup progress callback can be Fn.

This commit is contained in:
gwenn 2018-08-15 18:00:58 +02:00
parent e7d128c842
commit ec53f19be1

View File

@ -95,11 +95,11 @@ impl Connection {
/// ///
/// Will return `Err` if the destination path cannot be opened /// Will return `Err` if the destination path cannot be opened
/// or if the restore fails. /// or if the restore fails.
pub fn restore<P: AsRef<Path>>( pub fn restore<P: AsRef<Path>, F: Fn(Progress)>(
&mut self, &mut self,
name: DatabaseName, name: DatabaseName,
src_path: P, src_path: P,
progress: Option<fn(Progress)>, progress: Option<F>,
) -> Result<()> { ) -> Result<()> {
use self::StepResult::{Busy, Done, Locked, More}; use self::StepResult::{Busy, Done, Locked, More};
let src = try!(Connection::open(src_path)); let src = try!(Connection::open(src_path));
@ -109,7 +109,7 @@ impl Connection {
let mut busy_count = 0i32; let mut busy_count = 0i32;
'restore_loop: while r == More || r == Busy { 'restore_loop: while r == More || r == Busy {
r = try!(restore.step(100)); r = try!(restore.step(100));
if let Some(f) = progress { if let Some(ref f) = progress {
f(restore.progress()); f(restore.progress());
} }
if r == Busy { if r == Busy {