Module config

Source
Expand description

Application configuration management for AIM

This module provides functionality for managing application configuration including workspace paths, AI provider settings, and user preferences. Configuration is stored in platform-specific locations and loaded lazily on first access.

§Configuration Storage

Configuration is stored in TOML format in platform-specific directories:

  • Linux: ~/.config/{app_name}/{app_name}.toml
  • macOS: ~/Library/Application Support/net.imogen.{app_name}/{app_name}.toml
  • Windows: C:\Users\{username}\AppData\Roaming\imogen\{app_name}\config\{app_name}.toml

§Features

  • Thread-safe global singleton access
  • Runtime application name override
  • Dual provider configuration (local and external)
  • Automatic loading and saving

§Examples

use aimx::{AppName, get_config, get_config_mut};

// Set custom application name (must be done before any config access)
AppName::set("my_app");

// Access configuration for reading
let config = get_config();
let provider = config.read().unwrap().get_provider();

// Access configuration for writing
let mut config_guard = get_config_mut().expect("Failed to get config");
config_guard.workspace_path = "/path/to/workspace".to_string();
// Changes are automatically saved when guard is dropped

Structs§

AppName
Application name configuration
Config
Application configuration structure

Functions§

get_config
Returns the global singleton instance of the Config.
get_config_mut
Returns a mutable reference to the global singleton instance of the Config.