pub struct ModdeDb { /* private fields */ }Expand description
SQLite-backed persistent storage for modde.
Implementations§
Source§impl ModdeDb
impl ModdeDb
Sourcepub fn open() -> Result<Self>
pub fn open() -> Result<Self>
Open the database at the default XDG path, creating it if needed.
Sourcepub fn open_at(path: &Path) -> Result<Self>
pub fn open_at(path: &Path) -> Result<Self>
Open the database at a specific path (useful for testing).
Sourcepub fn open_memory() -> Result<Self>
pub fn open_memory() -> Result<Self>
Open an in-memory database (for testing).
Sourcepub fn create_profile(&self, profile: &Profile) -> Result<i64>
pub fn create_profile(&self, profile: &Profile) -> Result<i64>
Create a new profile, returning its database ID.
Sourcepub fn load_profile(&self, name: &str, game_id: &GameId) -> Result<Profile>
pub fn load_profile(&self, name: &str, game_id: &GameId) -> Result<Profile>
Load a profile by name and game_id.
Sourcepub fn load_profile_by_id(&self, id: i64) -> Result<Profile>
pub fn load_profile_by_id(&self, id: i64) -> Result<Profile>
Load a profile by its database ID.
Sourcepub fn load_profile_by_name(&self, name: &str) -> Result<Profile>
pub fn load_profile_by_name(&self, name: &str) -> Result<Profile>
Load a profile by name only. Errors with AmbiguousProfile if multiple games match.
Sourcepub fn update_profile(&self, profile: &Profile) -> Result<()>
pub fn update_profile(&self, profile: &Profile) -> Result<()>
Update an existing profile (identified by name + game_id).
Sourcepub fn delete_profile(&self, name: &str, game_id: &GameId) -> Result<()>
pub fn delete_profile(&self, name: &str, game_id: &GameId) -> Result<()>
Delete a profile by name and game_id.
Sourcepub fn list_profiles(
&self,
game_id: Option<&GameId>,
) -> Result<Vec<ProfileSummary>>
pub fn list_profiles( &self, game_id: Option<&GameId>, ) -> Result<Vec<ProfileSummary>>
List profile summaries, optionally filtered by game.
Sourcepub fn assign_save(
&self,
profile_id: i64,
path: &Path,
label: Option<&str>,
) -> Result<()>
pub fn assign_save( &self, profile_id: i64, path: &Path, label: Option<&str>, ) -> Result<()>
Assign a save to a profile.
Sourcepub fn unassign_save(&self, path: &Path) -> Result<()>
pub fn unassign_save(&self, path: &Path) -> Result<()>
Remove a save assignment.
Sourcepub fn list_saves(&self, profile_id: i64) -> Result<Vec<SaveEntry>>
pub fn list_saves(&self, profile_id: i64) -> Result<Vec<SaveEntry>>
List all saves assigned to a profile.
Sourcepub fn is_save_assigned(&self, path: &Path) -> Result<bool>
pub fn is_save_assigned(&self, path: &Path) -> Result<bool>
Check if a save path is assigned to any profile.
Sourcepub fn set_active_profile(
&self,
game_id: &GameId,
profile_id: i64,
) -> Result<()>
pub fn set_active_profile( &self, game_id: &GameId, profile_id: i64, ) -> Result<()>
Set the active profile for a game, replacing any previous one.
Sourcepub fn get_active_profile(
&self,
game_id: &GameId,
) -> Result<Option<(i64, String)>>
pub fn get_active_profile( &self, game_id: &GameId, ) -> Result<Option<(i64, String)>>
Get the active profile for a game, returning (profile_id, profile_name).
Sourcepub fn clear_active_profile(&self, game_id: &GameId) -> Result<()>
pub fn clear_active_profile(&self, game_id: &GameId) -> Result<()>
Clear the active profile for a game.
Sourcepub fn push_experiment(&self, game_id: &GameId, profile_id: i64) -> Result<()>
pub fn push_experiment(&self, game_id: &GameId, profile_id: i64) -> Result<()>
Push a profile onto the experiment stack for a game.
Sourcepub fn pop_experiment(&self, game_id: &GameId) -> Result<Option<i64>>
pub fn pop_experiment(&self, game_id: &GameId) -> Result<Option<i64>>
Pop the top entry from the experiment stack, returning the profile_id.
Sourcepub fn experiment_depth(&self, game_id: &GameId) -> Result<usize>
pub fn experiment_depth(&self, game_id: &GameId) -> Result<usize>
Get the experiment stack depth for a game.
Sourcepub fn clear_experiment_stack(&self, game_id: &GameId) -> Result<()>
pub fn clear_experiment_stack(&self, game_id: &GameId) -> Result<()>
Clear the entire experiment stack for a game.
Sourcepub fn upsert_snapshot(
&self,
game_id: &GameId,
snapshot_path: &Path,
tree_hash: &str,
file_count: usize,
) -> Result<()>
pub fn upsert_snapshot( &self, game_id: &GameId, snapshot_path: &Path, tree_hash: &str, file_count: usize, ) -> Result<()>
Insert or update a stock snapshot record.
Sourcepub fn get_snapshot(&self, game_id: &GameId) -> Result<Option<SnapshotMeta>>
pub fn get_snapshot(&self, game_id: &GameId) -> Result<Option<SnapshotMeta>>
Get snapshot metadata for a game.
Sourcepub fn hide_file(
&self,
profile_id: i64,
mod_id: &ModId,
rel_path: &str,
) -> Result<()>
pub fn hide_file( &self, profile_id: i64, mod_id: &ModId, rel_path: &str, ) -> Result<()>
Hide a file from a mod in a profile (prevents deployment).
Sourcepub fn unhide_file(
&self,
profile_id: i64,
mod_id: &ModId,
rel_path: &str,
) -> Result<()>
pub fn unhide_file( &self, profile_id: i64, mod_id: &ModId, rel_path: &str, ) -> Result<()>
Unhide a previously hidden file.
List all hidden files for a profile.
List hidden files for a specific mod in a profile.
Sourcepub fn set_plugin_order(
&self,
profile_id: i64,
plugins: &[PluginEntry],
) -> Result<()>
pub fn set_plugin_order( &self, profile_id: i64, plugins: &[PluginEntry], ) -> Result<()>
Set the plugin order for a profile (replaces any existing order).
Sourcepub fn get_plugin_order(&self, profile_id: i64) -> Result<Vec<PluginEntry>>
pub fn get_plugin_order(&self, profile_id: i64) -> Result<Vec<PluginEntry>>
Get the plugin order for a profile.
Sourcepub fn toggle_plugin(
&self,
profile_id: i64,
plugin_name: &str,
enabled: bool,
) -> Result<()>
pub fn toggle_plugin( &self, profile_id: i64, plugin_name: &str, enabled: bool, ) -> Result<()>
Toggle a plugin’s enabled state.
Sourcepub fn create_category(
&self,
profile_id: i64,
category: &ModCategory,
) -> Result<i64>
pub fn create_category( &self, profile_id: i64, category: &ModCategory, ) -> Result<i64>
Create a mod category, returning its ID.
Sourcepub fn update_category(
&self,
category_id: i64,
name: &str,
color: Option<&str>,
sort_index: i64,
) -> Result<()>
pub fn update_category( &self, category_id: i64, name: &str, color: Option<&str>, sort_index: i64, ) -> Result<()>
Update a category.
Sourcepub fn delete_category(&self, category_id: i64) -> Result<()>
pub fn delete_category(&self, category_id: i64) -> Result<()>
Delete a category (nullifies category_id on affected mods).
Sourcepub fn list_categories(&self, profile_id: i64) -> Result<Vec<ModCategory>>
pub fn list_categories(&self, profile_id: i64) -> Result<Vec<ModCategory>>
List categories for a profile.
Sourcepub fn set_mod_category(
&self,
profile_id: i64,
mod_id: &ModId,
category_id: Option<i64>,
) -> Result<()>
pub fn set_mod_category( &self, profile_id: i64, mod_id: &ModId, category_id: Option<i64>, ) -> Result<()>
Assign a mod to a category.
Sourcepub fn set_mod_notes(
&self,
profile_id: i64,
mod_id: &ModId,
notes: Option<&str>,
) -> Result<()>
pub fn set_mod_notes( &self, profile_id: i64, mod_id: &ModId, notes: Option<&str>, ) -> Result<()>
Set notes for a mod.
Set tags for a mod (stored as a JSON array in the TEXT column).
Sourcepub fn set_mod_nexus_meta(
&self,
profile_id: i64,
mod_id: &ModId,
nexus_mod_id: NexusModId,
nexus_file_id: NexusFileId,
nexus_game_domain: &str,
installed_timestamp: i64,
) -> Result<()>
pub fn set_mod_nexus_meta( &self, profile_id: i64, mod_id: &ModId, nexus_mod_id: NexusModId, nexus_file_id: NexusFileId, nexus_game_domain: &str, installed_timestamp: i64, ) -> Result<()>
Set Nexus metadata for a mod.
Sourcepub fn record_install(
&mut self,
profile_id: i64,
mod_id: &ModId,
plan: &InstallPlan,
status: InstallStatus,
) -> Result<()>
pub fn record_install( &mut self, profile_id: i64, mod_id: &ModId, plan: &InstallPlan, status: InstallStatus, ) -> Result<()>
Persist an installer’s decision and file manifest for a single mod row, atomically.
Steps in one transaction:
- Write the encoded
install_method,source_archive_hash, andinstall_statusback toprofile_mods. - Wipe any previous
installed_mod_filesrows for this mod (so retries don’t leave orphans in the manifest). - Insert one row per
plan.staged_files.
Callers are expected to have already written the EnabledMod into
the profile (via update_profile / create_profile); this method
just enriches the existing row with install metadata and files.
Sourcepub fn installed_files_for_mod(
&self,
profile_id: i64,
mod_id: &ModId,
) -> Result<Vec<StagedFile>>
pub fn installed_files_for_mod( &self, profile_id: i64, mod_id: &ModId, ) -> Result<Vec<StagedFile>>
Return every file staged by mod_id in profile_id, sorted by
relative path for deterministic uninstall order.
Sourcepub fn remove_installed_mod(
&mut self,
profile_id: i64,
mod_id: &ModId,
) -> Result<Vec<StagedFile>>
pub fn remove_installed_mod( &mut self, profile_id: i64, mod_id: &ModId, ) -> Result<Vec<StagedFile>>
Remove a mod from profile_mods and return its staged files so
the caller can unlink them from the store / deploy dir. Runs in
one transaction — either the manifest and row both disappear or
neither does.
Sourcepub fn files_in_merge_group(
&self,
profile_id: i64,
merge_group: &str,
) -> Result<Vec<(String, StagedFile)>>
pub fn files_in_merge_group( &self, profile_id: i64, merge_group: &str, ) -> Result<Vec<(String, StagedFile)>>
Return every file tagged with merge_group, across all mods in
profile_id. Reserved for the future script-merge feature —
unused by current code, but exposed now so the V8 schema can
carry a stable query shape.
Sourcepub fn import_toml_profiles(&self, profiles_dir: &Path) -> Result<usize>
pub fn import_toml_profiles(&self, profiles_dir: &Path) -> Result<usize>
Import existing TOML profile files into the database. Returns the number of profiles imported.
Source§impl ModdeDb
impl ModdeDb
Sourcepub fn save_tool_config(
&self,
game_id: &GameId,
tool_id: &str,
enabled: bool,
settings_json: &str,
) -> Result<()>
pub fn save_tool_config( &self, game_id: &GameId, tool_id: &str, enabled: bool, settings_json: &str, ) -> Result<()>
Save (insert or update) a tool configuration for a game.
Sourcepub fn save_tool_config_with_reason(
&self,
game_id: &GameId,
tool_id: &str,
enabled: bool,
settings_json: &str,
reason: &str,
) -> Result<()>
pub fn save_tool_config_with_reason( &self, game_id: &GameId, tool_id: &str, enabled: bool, settings_json: &str, reason: &str, ) -> Result<()>
Save a tool configuration and append a history node.
Sourcepub fn list_tool_setting_history(
&self,
game_id: &GameId,
tool_id: &str,
limit: usize,
) -> Result<Vec<ToolSettingHistoryNode>>
pub fn list_tool_setting_history( &self, game_id: &GameId, tool_id: &str, limit: usize, ) -> Result<Vec<ToolSettingHistoryNode>>
Load recent settings history nodes for a tool.
Sourcepub fn list_tool_setting_edges(
&self,
game_id: &GameId,
tool_id: &str,
) -> Result<Vec<ToolSettingHistoryEdge>>
pub fn list_tool_setting_edges( &self, game_id: &GameId, tool_id: &str, ) -> Result<Vec<ToolSettingHistoryEdge>>
Load DAG edges for a tool’s recorded settings history.
Sourcepub fn restore_tool_setting_node(
&self,
game_id: &GameId,
tool_id: &str,
node_id: &str,
) -> Result<()>
pub fn restore_tool_setting_node( &self, game_id: &GameId, tool_id: &str, node_id: &str, ) -> Result<()>
Restore a settings node by appending a new child node with copied state.
Sourcepub fn load_tool_configs(&self, game_id: &GameId) -> Result<Vec<ToolConfigRow>>
pub fn load_tool_configs(&self, game_id: &GameId) -> Result<Vec<ToolConfigRow>>
Load all tool configurations for a game.
Sourcepub fn load_tool_config(
&self,
game_id: &GameId,
tool_id: &str,
) -> Result<Option<ToolConfigRow>>
pub fn load_tool_config( &self, game_id: &GameId, tool_id: &str, ) -> Result<Option<ToolConfigRow>>
Load a single tool configuration for a game.
Sourcepub fn save_applied_files(
&self,
game_id: &GameId,
tool_id: &str,
rel_paths: &[String],
) -> Result<()>
pub fn save_applied_files( &self, game_id: &GameId, tool_id: &str, rel_paths: &[String], ) -> Result<()>
Record files applied by a tool to a game directory.
Sourcepub fn load_applied_files(
&self,
game_id: &GameId,
tool_id: &str,
) -> Result<Vec<String>>
pub fn load_applied_files( &self, game_id: &GameId, tool_id: &str, ) -> Result<Vec<String>>
Load files previously applied by a tool.
Sourcepub fn clear_applied_files(&self, game_id: &GameId, tool_id: &str) -> Result<()>
pub fn clear_applied_files(&self, game_id: &GameId, tool_id: &str) -> Result<()>
Clear all applied file records for a tool on a game.
Sourcepub fn save_executable_config(
&self,
executable: &ExecutableConfigRow,
) -> Result<()>
pub fn save_executable_config( &self, executable: &ExecutableConfigRow, ) -> Result<()>
Save or update a named executable for a game.
Sourcepub fn load_executable_configs(
&self,
game_id: &GameId,
) -> Result<Vec<ExecutableConfigRow>>
pub fn load_executable_configs( &self, game_id: &GameId, ) -> Result<Vec<ExecutableConfigRow>>
Load every executable configured for a game, ordered by display name.
Sourcepub fn load_executable_config(
&self,
game_id: &GameId,
name: &str,
) -> Result<Option<ExecutableConfigRow>>
pub fn load_executable_config( &self, game_id: &GameId, name: &str, ) -> Result<Option<ExecutableConfigRow>>
Load a single named executable for a game.