Struct BLSEntry

Source
pub struct BLSEntry {
Show 16 fields pub title: Option<BLSValue>, pub version: Option<BLSValue>, pub machine_id: Option<BLSValue>, pub sort_key: Option<BLSValue>, pub linux: BLSValue, pub efi: Option<BLSValue>, pub initrd: Vec<BLSValue>, pub options: Vec<BLSValue>, pub devicetree: Option<BLSValue>, pub devicetree_overlay: Option<BLSValue>, pub architecture: Option<BLSValue>, pub grub_hotkey: Option<BLSValue>, pub grub_users: Option<BLSValue>, pub grub_class: Vec<BLSValue>, pub grub_arg: Option<BLSValue>, pub comments: Vec<String>,
}
Expand description

BLSEntry represents the contents of a BLS entry file

Fields§

§title: Option<BLSValue>§version: Option<BLSValue>§machine_id: Option<BLSValue>§sort_key: Option<BLSValue>§linux: BLSValue§efi: Option<BLSValue>§initrd: Vec<BLSValue>§options: Vec<BLSValue>§devicetree: Option<BLSValue>§devicetree_overlay: Option<BLSValue>§architecture: Option<BLSValue>§grub_hotkey: Option<BLSValue>§grub_users: Option<BLSValue>§grub_class: Vec<BLSValue>§grub_arg: Option<BLSValue>§comments: Vec<String>

Implementations§

Source§

impl BLSEntry

Source

pub fn new() -> BLSEntry

Allocates a new instance of BLSEntry, all optional members are initialized to None and linux is set with an empty string

Source

pub fn parse(buffer: &str) -> Result<BLSEntry, String>

Parses a Boot Loader Spec entry UTF-8 buffer, returns a BLSEntry instance if successful, an error String if there was an error Note that any comment lines that are then rendered using BLSEntry::parse() will be pushed to the header of the file as the order commands and comments are not preserved.

Source

pub fn render(&self) -> String

Renders the BLSEntry content into a UTF-8 String

Source

pub fn set( &mut self, key: BLSKey, value: String, comment: Option<String>, set_policy: ValueSetPolicy, )

Sets a value for a given key

§Arguments
  • key: a &str representing the key to be set
  • value: a String representing the value for the key
  • comment: an optional String reprensenting an inline comment for the value
  • set_policy: Some keys can hold multiple values, the ValueSetPolicy enum specifies the policy for keys that can be specified multiple times.
§Panics

If ValueSetPolicy::InsertAt(usize) is used as set_policy it may cause a panic if the index is out of bound

Source

pub fn clear(&mut self, key: BLSKey)

Clears a field in the BLSEntry

§Arguments
  • key: The BLSKey to clear. Note that if BLSKey::linux is used it will set it to an empty string as this key is always supposed to be present. Sets None or empty vector otherwise.

Trait Implementations§

Source§

impl Debug for BLSEntry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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, 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.