pub struct SystemdBootConf {
pub efi_mount: Box<Path>,
pub entries_path: Box<Path>,
pub loader_path: Box<Path>,
pub entries: Vec<Entry>,
pub loader_conf: LoaderConf,
}
Fields§
§efi_mount: Box<Path>
§entries_path: Box<Path>
§loader_path: Box<Path>
§entries: Vec<Entry>
§loader_conf: LoaderConf
Implementations§
Source§impl SystemdBootConf
impl SystemdBootConf
Sourcepub fn new<P: Into<PathBuf>>(efi_mount: P) -> Result<Self, Error>
pub fn new<P: Into<PathBuf>>(efi_mount: P) -> Result<Self, Error>
Examples found in repository?
examples/list.rs (line 7)
6pub fn main() {
7 let manager = match SystemdBootConf::new("/boot/efi") {
8 Ok(manager) => manager,
9 Err(why) => {
10 eprintln!("failed to get systemd-boot info: {}", why);
11 exit(1);
12 }
13 };
14
15 println!(
16 "loader:\n default: {:?}\n timeout: {:?}",
17 manager.loader_conf.default, manager.loader_conf.timeout
18 );
19
20 for entry in manager.entries {
21 println!(
22 " id: {}\n title: {}\n linux: {}\n initrd: {:?}\n options: {:?}",
23 entry.id, entry.title, entry.linux, entry.initrd, entry.options
24 );
25 }
26}
More examples
examples/timeout.rs (line 7)
6pub fn main() {
7 let mut manager = match SystemdBootConf::new("/boot/efi") {
8 Ok(manager) => manager,
9 Err(why) => {
10 eprintln!("failed to get systemd-boot info: {}", why);
11 exit(1);
12 }
13 };
14
15 manager.loader_conf.timeout = Some(10);
16 if let Err(why) = manager.overwrite_loader_conf() {
17 eprintln!("failed to overwrite systemd-boot loader: {}", why);
18 exit(1);
19 }
20
21 println!("successfully overwrote loader conf");
22 if let Err(why) = manager.load_conf() {
23 eprintln!("failed to reload systemd-boot loader conf: {}", why);
24 exit(1);
25 }
26
27 println!(
28 "loader:\n default: {:?}\n timeout: {:?}",
29 manager.loader_conf.default, manager.loader_conf.timeout
30 );
31}
Sourcepub fn current_entry(&self) -> Option<&Entry>
pub fn current_entry(&self) -> Option<&Entry>
Find the boot entry which matches the current boot
§Implementation
The current boot option is determined by a matching the entry’s initd and options
to /proc/cmdline
.
Sourcepub fn default_entry_exists(&self) -> DefaultState
pub fn default_entry_exists(&self) -> DefaultState
Validate that the default entry exists.
Sourcepub fn entry_exists(&self, entry: &str) -> bool
pub fn entry_exists(&self, entry: &str) -> bool
Validates that an entry exists with this name.
Sourcepub fn get(&self, entry: &str) -> Option<&Entry>
pub fn get(&self, entry: &str) -> Option<&Entry>
Get the entry that corresponds to the given name.
Sourcepub fn get_mut(&mut self, entry: &str) -> Option<&mut Entry>
pub fn get_mut(&mut self, entry: &str) -> Option<&mut Entry>
Get a mutable entry that corresponds to the given name.
Sourcepub fn load_conf(&mut self) -> Result<(), Error>
pub fn load_conf(&mut self) -> Result<(), Error>
Attempt to re-read the loader configuration.
Examples found in repository?
examples/timeout.rs (line 22)
6pub fn main() {
7 let mut manager = match SystemdBootConf::new("/boot/efi") {
8 Ok(manager) => manager,
9 Err(why) => {
10 eprintln!("failed to get systemd-boot info: {}", why);
11 exit(1);
12 }
13 };
14
15 manager.loader_conf.timeout = Some(10);
16 if let Err(why) = manager.overwrite_loader_conf() {
17 eprintln!("failed to overwrite systemd-boot loader: {}", why);
18 exit(1);
19 }
20
21 println!("successfully overwrote loader conf");
22 if let Err(why) = manager.load_conf() {
23 eprintln!("failed to reload systemd-boot loader conf: {}", why);
24 exit(1);
25 }
26
27 println!(
28 "loader:\n default: {:?}\n timeout: {:?}",
29 manager.loader_conf.default, manager.loader_conf.timeout
30 );
31}
Sourcepub fn load_entries(&mut self) -> Result<(), Error>
pub fn load_entries(&mut self) -> Result<(), Error>
Attempt to load all of the available entries in the system.
Sourcepub fn overwrite_loader_conf(&self) -> Result<(), Error>
pub fn overwrite_loader_conf(&self) -> Result<(), Error>
Overwrite the conf file with stored values.
Examples found in repository?
examples/timeout.rs (line 16)
6pub fn main() {
7 let mut manager = match SystemdBootConf::new("/boot/efi") {
8 Ok(manager) => manager,
9 Err(why) => {
10 eprintln!("failed to get systemd-boot info: {}", why);
11 exit(1);
12 }
13 };
14
15 manager.loader_conf.timeout = Some(10);
16 if let Err(why) = manager.overwrite_loader_conf() {
17 eprintln!("failed to overwrite systemd-boot loader: {}", why);
18 exit(1);
19 }
20
21 println!("successfully overwrote loader conf");
22 if let Err(why) = manager.load_conf() {
23 eprintln!("failed to reload systemd-boot loader conf: {}", why);
24 exit(1);
25 }
26
27 println!(
28 "loader:\n default: {:?}\n timeout: {:?}",
29 manager.loader_conf.default, manager.loader_conf.timeout
30 );
31}
Trait Implementations§
Source§impl Clone for SystemdBootConf
impl Clone for SystemdBootConf
Source§fn clone(&self) -> SystemdBootConf
fn clone(&self) -> SystemdBootConf
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for SystemdBootConf
impl RefUnwindSafe for SystemdBootConf
impl Send for SystemdBootConf
impl Sync for SystemdBootConf
impl Unpin for SystemdBootConf
impl UnwindSafe for SystemdBootConf
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more