Struct ConfigBuilder

Source
pub struct ConfigBuilder { /* private fields */ }
Expand description

A builder to configure a Config

§Example

use bootmgr_rs_core::config::builder::ConfigBuilder;
use uefi::{boot, proto::{device_path::DevicePath, loaded_image::LoadedImage, media::fs::SimpleFileSystem}};

let handle = {
    let loaded_image =
        boot::open_protocol_exclusive::<LoadedImage>(boot::image_handle()).expect("Failed to open LoadedImage on image");
    let device_handle = loaded_image.device().expect("Image was not loaded from a filesystem");
    let device_path = boot::open_protocol_exclusive::<DevicePath>(device_handle).expect("Failed to get device path from image filesystem");
    boot::locate_device_path::<SimpleFileSystem>(&mut &*device_path).expect("Failed to get SimpleFileSystem on image filesystem")
};

let config = ConfigBuilder::new("foo.conf", ".conf")
    .title("foo")
    .fs_handle(handle)
    .build();

Implementations§

Source§

impl ConfigBuilder

Source

pub fn new(filename: impl Into<String>, suffix: impl Into<String>) -> Self

Constructs a new Config.

Source

pub fn title(self, title: impl Into<String>) -> Self

Sets the title of a Config.

Source

pub fn version(self, version: impl Into<String>) -> Self

Sets the version of a Config.

Source

pub fn machine_id(self, machine_id: impl Into<String>) -> Self

Sets the machine id of a Config.

This must be formatted as 32 lower case hexadecimal characters as defined in BootLoaderSpec. Otherwise, this will have no effect

Source

pub fn sort_key(self, sort_key: impl Into<String>) -> Self

Sets the sort key of a Config

Ideally, this should be entirely composed of lowercase characters, with nothing else other than numbers, dashes, underscores, and periods.

Source

pub fn options(self, options: impl Into<String>) -> Self

Sets the options of a Config

This essentially sets the LoadOptions, or the command line of an EFI shell

Source

pub fn devicetree_path(self, devicetree_path: impl Into<String>) -> Self

Sets the devicetree of a Config

Source

pub fn architecture(self, architecture: impl Into<String>) -> Self

Sets the architecture of a Config

This is only used for filtering entries

Source

pub const fn set_bad(self, bad: bool) -> Self

Sets if a Config is bad, so it may be deranked

Source

pub const fn action(self, action: BootAction) -> Self

Sets the BootAction of a Config

This can be one of BootAction::BootEfi, BootAction::BootTftp, BootAction::Reboot, BootAction::Shutdown, and BootAction::ResetToFirmware. You should never need to use this

Source

pub fn fs_handle(self, fs_handle: Handle) -> Self

Sets the Handle of a Config

This is used for filesystem operations, so it is required to be set to indicate which filesystem a Config comes from

Source

pub const fn origin(self, origin: Parsers) -> Self

Sets the origin of a Config.

This is one of the parsers that generate Configs.

Source

pub fn efi_path(self, efi_path: impl Into<String>) -> Self

Sets the EFI executable path of a Config.

Source

pub fn build(self) -> Config

Builds a Config

Source

pub fn assign_if_some<F, T>(self, value: Option<T>, assign: F) -> Self
where F: FnOnce(Self, T) -> Self,

Assigns a value to a field in a Config if it is Some.

Trait Implementations§

Source§

impl From<&Config> for ConfigBuilder

Source§

fn from(value: &Config) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.