Module persistence

Module persistence 

Source
Available on crate feature theme only.
Expand description

Theme persistence for saving and loading user theme preferences.

This module provides functions to save and load the user’s selected theme to a configuration file, allowing the preference to persist across sessions.

§Default Config Location

By default, the config is stored at:

  • Linux/macOS: ~/.config/ratatui-toolkit/theme.json
  • Windows: %APPDATA%\ratatui-toolkit\theme.json

§Example

use ratatui_toolkit::services::theme::persistence::{save_theme, load_saved_theme};

// Save the current theme
save_theme("ayu", None).ok();

// Load the saved theme on startup
if let Some(theme_name) = load_saved_theme(None) {
    println!("Loaded theme: {}", theme_name);
}

Structs§

ThemeConfig
Configuration structure for persisted theme settings.

Functions§

clear_saved_theme
Clears the saved theme preference.
default_config_dir
Gets the default config directory for theme settings.
default_config_path
Gets the default path for the theme config file.
load_saved_theme
Loads the saved theme name from the config file.
save_theme
Saves the selected theme to a config file.