Split import_ui::wire into one function per section

The 188-line wire() registered the import page's callbacks in four
comment-delimited sections. Lift each into its own fn: wire_opening_and_closing,
wire_choosing_a_source, wire_options, wire_running. context stays generic
over C on each of the three functions that use it, matching how survey()
and start() already take it (impl Fn, implicitly Sized) rather than coercing
it to a trait object, which would have needed ?Sized added to those two
unrelated functions for no benefit.
This commit is contained in:
2026-09-20 19:23:21 +02:00
parent beb7a5eac0
commit 5458314083
+31 -4
View File
@@ -310,7 +310,17 @@ where
let context = Rc::new(context);
let on_imported = Rc::new(on_imported);
// --- opening and closing ---------------------------------------------
wire_opening_and_closing(window, &ctl, &context);
wire_choosing_a_source(window, &ctl, &context);
wire_options(window, &ctl);
wire_running(window, &ctl, &context, &on_imported);
}
/// Opening and closing.
fn wire_opening_and_closing<C>(window: &AppWindow, ctl: &Rc<ImportController>, context: &Rc<C>)
where
C: Fn() -> Option<Context> + 'static,
{
{
let weak = window.as_weak();
let ctl = ctl.clone();
@@ -351,8 +361,13 @@ where
w.set_show_import(false);
});
}
}
// --- choosing a source -------------------------------------------------
/// Choosing a source.
fn wire_choosing_a_source<C>(window: &AppWindow, ctl: &Rc<ImportController>, context: &Rc<C>)
where
C: Fn() -> Option<Context> + 'static,
{
{
let weak = window.as_weak();
let ctl = ctl.clone();
@@ -395,8 +410,10 @@ where
render(&w, &ctl);
});
}
}
// --- options -----------------------------------------------------------
/// Options.
fn wire_options(window: &AppWindow, ctl: &Rc<ImportController>) {
{
let weak = window.as_weak();
let ctl = ctl.clone();
@@ -465,8 +482,18 @@ where
render(&w, &ctl);
});
}
}
// --- running -----------------------------------------------------------
/// Running.
fn wire_running<C, F>(
window: &AppWindow,
ctl: &Rc<ImportController>,
context: &Rc<C>,
on_imported: &Rc<F>,
) where
C: Fn() -> Option<Context> + 'static,
F: Fn() + 'static,
{
{
let weak = window.as_weak();
let ctl = ctl.clone();