BootdiskOptionsView::new(&state.runtime_info.disks, &state.options.bootdisk)
.with_name("bootdisk-options"),
Box::new(|siv| {
- let options = siv
- .call_on_name("bootdisk-options", BootdiskOptionsView::get_values)
- .flatten();
-
- if let Some(options) = options {
- siv.with_user_data(|state: &mut InstallerState| {
- state.options.bootdisk = options;
- });
-
- switch_to_next_screen(siv, InstallerStep::Timezone, &timezone_dialog);
- } else {
- siv.add_layer(Dialog::info("Invalid values"));
+ let options = siv.call_on_name("bootdisk-options", BootdiskOptionsView::get_values);
+
+ match options {
+ Some(Ok(options)) => {
+ siv.with_user_data(|state: &mut InstallerState| {
+ state.options.bootdisk = options;
+ });
+
+ switch_to_next_screen(siv, InstallerStep::Timezone, &timezone_dialog);
+ }
+
+ Some(Err(err)) => siv.add_layer(Dialog::info(format!("Invalid values: {err}"))),
+ _ => siv.add_layer(Dialog::info("Invalid values")),
}
}),
)
}
}
- pub fn get_values(&mut self) -> Option<BootdiskOptions> {
+ pub fn get_values(&mut self) -> Result<BootdiskOptions, String> {
let mut options = (*self.advanced_options).clone().into_inner();
if [FsType::Ext4, FsType::Xfs].contains(&options.fstype) {
let disk = self
.view
- .get_child_mut(0)?
- .downcast_mut::<NamedView<FormView>>()?
- .get_mut()
- .get_value::<SelectView<Disk>, _>(0)?;
+ .get_child_mut(0)
+ .and_then(|v| v.downcast_mut::<NamedView<FormView>>())
+ .map(NamedView::<FormView>::get_mut)
+ .and_then(|v| v.get_value::<SelectView<Disk>, _>(0))
+ .ok_or("failed to retrieve filesystem type")?;
options.disks = vec![disk];
}
- Some(options)
+ Ok(options)
}
}