Skip to main content
← OpenMECP Documentation

SettingsManager

Struct SettingsManager 

Source
pub struct SettingsManager {
    settings: Settings,
    config_source: String,
}
Expand description

Configuration manager that handles loading and accessing program settings.

Fields§

§settings: Settings§config_source: String

Implementations§

Source§

impl SettingsManager

Source

pub fn load() -> Result<Self, ConfigError>

Loads configuration from available configuration files.

Searches for configuration files in the following order:

  1. ./omecp_config.cfg (current working directory)
  2. ~/.config/omecp/omecp_config.cfg (user configuration)
  3. /etc/omecp/omecp_config.cfg (system configuration)
  4. Built-in defaults (fallback)
§Returns

Returns a Result containing:

  • Ok(SettingsManager) - Successfully loaded configuration
  • Err(ConfigError) - Configuration loading failed
§Examples
use omecp::settings::SettingsManager;

let settings = SettingsManager::load()?;
println!("Configuration loaded from: {}", settings.config_source());
Source

pub fn config_source(&self) -> &str

Returns the source of the loaded configuration.

Source

pub fn settings(&self) -> &Settings

Gets a reference to the settings.

§Returns

Returns a reference to the internal Settings struct

Source

pub fn get_output_extension(&self, program: QMProgram) -> &str

Gets the output file extension for the specified QM program.

§Arguments
  • program - The quantum chemistry program
§Returns

The file extension (without the dot) as a string slice

§Examples
use omecp::config::QMProgram;
use omecp::settings::SettingsManager;

let settings = SettingsManager::load()?;
let extension = settings.get_output_extension(QMProgram::Orca);
assert_eq!(extension, "out");
Source

pub fn general(&self) -> &GeneralSettings

Gets the general settings.

Source

pub fn general_mut(&mut self) -> &mut GeneralSettings

Gets mutable general settings.

Source

pub fn logging(&self) -> &LoggingSettings

Gets the logging settings.

Source

pub fn extensions(&self) -> &ExtensionSettings

Gets the extension settings.

Source

pub fn cleanup(&self) -> &CleanupSettings

Gets the cleanup settings.

Source

fn load_from_files() -> Result<(Settings, String), ConfigError>

Loads configuration from files with hierarchical precedence.

Source

fn load_config(path: &Path) -> Result<Settings, ConfigError>

Loads configuration from a single INI file.

Source

fn parse_extensions( section: &HashMap<String, Option<String>>, ) -> Result<ExtensionSettings, ConfigError>

Parses the extensions section from INI configuration.

Source

fn parse_general( section: &HashMap<String, Option<String>>, ) -> Result<GeneralSettings, ConfigError>

Parses the general section from INI configuration.

Source

fn parse_logging( section: &HashMap<String, Option<String>>, ) -> Result<LoggingSettings, ConfigError>

Parses the logging section from INI configuration.

Source

fn parse_cleanup( section: &HashMap<String, Option<String>>, ) -> Result<CleanupSettings, ConfigError>

Parses the cleanup section from INI configuration.

Source

fn get_system_config_path() -> Option<PathBuf>

Gets the system configuration file path.

Source

fn get_user_config_path() -> Option<PathBuf>

Gets the user configuration file path.

Source§

impl SettingsManager

Source

pub fn create_template(path: &Path) -> Result<(), ConfigError>

Creates a default omecp_config.cfg file with all available configuration options.

This function generates a comprehensive configuration file template with:

  • All available configuration sections and parameters
  • Default values for each parameter
  • Detailed comments explaining each option
  • Examples of common customizations
§Arguments
  • path - Path where the omecp_config.cfg file should be created
§Returns

Returns a Result indicating success or failure of file creation

§Examples
use omecp::settings::SettingsManager;
use std::path::Path;

SettingsManager::create_template(Path::new("omecp_config.cfg"))?;
Source

fn generate_template_content() -> String

Generates the content for a omecp_config.cfg template file.

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> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.