move some code to utils and move around functions

This commit is contained in:
2025-10-01 21:30:43 -07:00
parent 3b8243d401
commit 8a2c08bb57
5 changed files with 45 additions and 39 deletions

View File

@@ -1,7 +1,5 @@
use crate::utils;
use serde::{Deserialize, Serialize};
use uefi::cstr16;
use uefi::fs::{FileSystem, Path};
use uefi::proto::media::fs::SimpleFileSystem;
#[derive(Serialize, Deserialize, Default)]
pub struct RootConfiguration {
@@ -21,13 +19,6 @@ pub struct ChainloaderConfiguration {
}
pub fn load() -> RootConfiguration {
let fs = uefi::boot::open_protocol_exclusive::<SimpleFileSystem>(
uefi::boot::get_handle_for_protocol::<SimpleFileSystem>().expect("no filesystem protocol"),
)
.expect("unable to open filesystem protocol");
let mut fs = FileSystem::new(fs);
let content = fs
.read(Path::new(cstr16!("sprout.toml")))
.expect("unable to read sprout.toml file");
let content = utils::read_file_contents("sprout.toml");
toml::from_slice(&content).expect("unable to parse sprout.toml file")
}