Fix progress_fn type

This commit is contained in:
RumovZ 2022-04-17 09:35:56 +02:00
parent e65b79ba63
commit 16f8c980a6

View file

@ -20,19 +20,21 @@ use crate::{
search::SearchNode, search::SearchNode,
}; };
type ProgressFn = dyn FnMut(ImportProgress) -> Result<()>;
struct Context<'a> { struct Context<'a> {
target_col: &'a mut Collection, target_col: &'a mut Collection,
archive: ZipArchive<File>, archive: ZipArchive<File>,
data: ExchangeData, data: ExchangeData,
usn: Usn, usn: Usn,
progress_fn: &'a mut dyn Fn(ImportProgress) -> Result<()>, progress_fn: &'a mut ProgressFn,
} }
impl Collection { impl Collection {
pub fn import_apkg( pub fn import_apkg(
&mut self, &mut self,
path: impl AsRef<Path>, path: impl AsRef<Path>,
progress_fn: &mut dyn Fn(ImportProgress) -> Result<()>, progress_fn: &mut ProgressFn,
) -> Result<OpOutput<()>> { ) -> Result<OpOutput<()>> {
let file = File::open(path)?; let file = File::open(path)?;
let archive = ZipArchive::new(file)?; let archive = ZipArchive::new(file)?;
@ -48,7 +50,7 @@ impl<'a> Context<'a> {
fn new( fn new(
mut archive: ZipArchive<File>, mut archive: ZipArchive<File>,
target_col: &'a mut Collection, target_col: &'a mut Collection,
progress_fn: &'a mut dyn Fn(ImportProgress) -> Result<()>, progress_fn: &'a mut ProgressFn,
) -> Result<Self> { ) -> Result<Self> {
let data = let data =
ExchangeData::gather_from_archive(&mut archive, SearchNode::WholeCollection, true)?; ExchangeData::gather_from_archive(&mut archive, SearchNode::WholeCollection, true)?;