Configuration types and config-file I/O.
Tutorial overview
This module defines the persistent configuration for the CLI, stored at
~/.config/g/config.toml. It uses serde and toml to map Rust structs
directly to a human-readable file format, and provides helper functions for
locating, loading, saving, and bootstrapping the config.
Rust concepts used here
#[derive(Serialize, Deserialize)]automatically generates TOML conversion code at compile time — no manual parsing needed.HashMap<String, String>for dynamic key-value storage (git aliases).- The [
Default] trait gives every config section a sensible baseline so users only need to override what they care about. fs::create_dir_allandfs::writefor managing the local filesystem.anyhow::Contextattaches a human-readable message to anyResulterror, making it much easier to diagnose file I/O failures.
Source:
src/config/mod.rs