1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-07-07 05:01:03 +02:00

docs: add some rustdoc comments throughout

This commit is contained in:
Jake Stanger 2022-08-28 16:57:41 +01:00
parent 5d319e91f2
commit 78e30b39fe
16 changed files with 84 additions and 2 deletions

View file

@ -71,6 +71,8 @@ const fn default_bar_height() -> i32 {
}
impl Config {
/// Attempts to load the config file from file,
/// parse it and return a new instance of `Self`.
pub fn load() -> Result<Self> {
let config_path = if let Ok(config_path) = env::var("IRONBAR_CONFIG") {
let path = PathBuf::from(config_path);
@ -87,6 +89,10 @@ impl Config {
Self::load_file(&config_path)
}
/// Attempts to discover the location of the config file
/// by checking each valid format's extension.
///
/// Returns the path of the first valid match, if any.
fn try_find_config() -> Result<PathBuf> {
let config_dir = config_dir().wrap_err("Failed to locate user config dir")?;
@ -110,6 +116,8 @@ impl Config {
}
}
/// Loads the config file at the specified path
/// and parses it into `Self` based on its extension.
fn load_file(path: &Path) -> Result<Self> {
let file = fs::read(path).wrap_err("Failed to read config file")?;
let extension = path