ConfigRegistry

Struct ConfigRegistry 

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

The ConfigRegistry is used to create a registry, which allows reading and writing a configuration to and from a .config file as defined by a Kconfig file. To present the menu, a frontend is necessary to represent the state of the registry.

Implementations§

Source§

impl ConfigRegistry

Source

pub fn new(ast: &Ast, macro_symbols: &HashSet<Symbol>) -> Result<Self, Error>

Constructs a new configuration registry, given the Abstract syntax tree as loaded from a kconfig-parser’s Ast instance, and the macro symbols discoverd by the macro lexer (if used).

Source

pub fn items<'a>(&'a self) -> &'a HashMap<ItemReference, Item>

Return a reference to the map of the items available in the configuration registry

Source

pub fn main_menu_name<'a>(&'a self) -> &'a str

Returns the name of the main menu

Source

pub fn main_menu_item<'a>(&'a self) -> &'a Item

Returns the item belonging to the main menu

Source

pub fn get<'a>(&'a self, itemref: &ItemReference) -> Option<&'a Item>

Finds the item given the item reference, if available, otherwise returns None

Source

pub fn get_info(&self, itemref: &ItemReference) -> Option<Info>

Returns an item’s information, if available, otherwise returns None

Source

pub fn item_enabled(&self, itemref: &ItemReference) -> Result<bool, Error>

Given the item reference, determine whether the associated item is enabled

Source

pub fn current_config_item(&self, itemref: &ItemReference) -> Option<ConfigItem>

Returns a clone of the active configuration item, if available

Source

pub fn mutation_start(&self, itemref: &ItemReference) -> Option<MutationStart>

Returns how to start a mutation. Given the configuration type, this can be a different start situation.

Source

pub fn current_value(&self, itemref: &ItemReference) -> Option<Variant>

The current value of an item is resolved according to a number of rules:

If the value has been selected through a select reverse dependency, then this value will be used, with respect to it’s default value.

If the value has a “regular” value, then this value will be used

If the value has been selected through an implied value, then this value will be used, with respect to it’s default value.

Otherwise, the default value will be used.

Source

pub fn current_value_is_default(&self, itemref: &ItemReference) -> bool

Determines whether the value if the configuration item internal to the item is set to it’s default value.

Source

pub fn set_value( &mut self, itemref: &ItemReference, value: Variant, ) -> Result<(), Error>

Sets the value of a configuration item either by loading it from an earlier stored session, or by entering the data programmatically/through a configuration editor. Returns nothing if successful, or an error if for some reason the value could not be set properly.

Source

pub fn discard_value(&mut self, itemref: &ItemReference) -> Result<(), Error>

Unsets the value of a configuation item

Source

pub fn find_itemref(&self, name: &str) -> Option<ItemReference>

Finds the appropriate item reference by the name of the itemreference

Source

pub fn reset(&mut self) -> Result<(), Error>

Evaluates all items and enforces the proper rules on all internal configuration items and dependent configuration items for all the items evaluated.

Source

pub fn write_dotconfig_file( &self, dotconfig_filename: &str, ) -> Result<(), Error>

Writes the current configuration known to the configuration registry into a file, typically this file has the file name “.config”

Source

pub fn write_dotconfig(&self, output: &mut dyn Write) -> Result<(), Error>

Writes the current configuration known to the configuration registry into a Write trait supporting type.

Source

pub fn read_dotconfig_file( &mut self, dotconfig_filename: &str, ) -> Result<(), LoadError>

Reads the saved configuration from a file, typically this file has the file name “.config”, and mutates the configuration registry accordingly.

Source

pub fn read_dotconfig(&mut self, input: &mut dyn Read) -> Result<(), LoadError>

Reads the saved configuration from a Read trait supporting type, and mutates the configuration registry accordingly.

Trait Implementations§

Source§

impl Debug for ConfigRegistry

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.