Skip to content

Commit 7825e03

Browse files
author
Gareth Widlansky
committed
use option rather than an enum
Signed-off-by: Gareth Widlansky <gareth.widlansky@proton.me>
1 parent 16ba8ca commit 7825e03

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

crates/lib/src/bootc_composefs/boot.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,17 +1144,17 @@ pub(crate) fn setup_composefs_uki_boot(
11441144
Ok(())
11451145
}
11461146

1147-
pub enum AutoEnroll {
1148-
None,
1149-
Keys { dir: Dir, keys: Vec<Utf8PathBuf> },
1147+
pub struct AutoEnroll {
1148+
pub dir: Dir,
1149+
pub keys: Vec<Utf8PathBuf>,
11501150
}
11511151

1152-
fn get_systemd_boot_autoenroll(fs: &Dir, p: &str) -> Result<AutoEnroll> {
1152+
fn get_systemd_boot_autoenroll(fs: &Dir, p: &str) -> Result<Option<AutoEnroll>> {
11531153
let mut entries = vec![];
11541154

11551155
let keys_dir = match fs.open_dir(p) {
11561156
Ok(d) => d,
1157-
Err(_) => return Ok(AutoEnroll::None), // if the directory doesn't exist it just means we don't have any keys to enroll
1157+
Err(_) => return Ok(None), // if the directory doesn't exist it just means we don't have any keys to enroll
11581158
};
11591159

11601160
for entry in keys_dir.entries()? {
@@ -1176,12 +1176,12 @@ fn get_systemd_boot_autoenroll(fs: &Dir, p: &str) -> Result<AutoEnroll> {
11761176
entries.push(path);
11771177
}
11781178
if entries.len() > 0 {
1179-
return Ok(AutoEnroll::Keys {
1179+
return Ok(Some(AutoEnroll {
11801180
dir: keys_dir,
11811181
keys: entries,
1182-
});
1182+
}));
11831183
}
1184-
return Ok(AutoEnroll::None);
1184+
return Ok(None);
11851185
}
11861186

11871187
#[context("Setting up composefs boot")]

crates/lib/src/bootloader.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub(crate) fn install_systemd_boot(
7878
_rootfs: &Utf8Path,
7979
_configopts: &crate::install::InstallConfigOpts,
8080
_deployment_path: Option<&str>,
81-
autoenroll: AutoEnroll,
81+
autoenroll: Option<AutoEnroll>,
8282
) -> Result<()> {
8383
let esp_part = device
8484
.find_partition_of_type(discoverable_partition_specification::ESP)
@@ -95,8 +95,8 @@ pub(crate) fn install_systemd_boot(
9595
.run_inherited_with_cmd_context()?;
9696

9797
match autoenroll {
98-
AutoEnroll::None => return Ok(()),
99-
AutoEnroll::Keys { dir, keys } => {
98+
None => return Ok(()),
99+
Some(AutoEnroll { dir, keys }) => {
100100
println!("Autoenrolling keys");
101101
let path = esp_path.join(SYSTEMD_AUTOENROLL);
102102
create_dir_all(&path)?;

0 commit comments

Comments
 (0)