pub struct ModdeDb { /* private fields */ }Expand description
SQLite/PostgreSQL-backed persistent storage for modde.
Implementations§
Source§impl ModdeDb
impl ModdeDb
Sourcepub async fn open() -> Result<Self>
pub async fn open() -> Result<Self>
Open the database selected by configuration (settings + environment),
creating/migrating it as needed. Defaults to SQLite at the XDG path.
Sourcepub async fn open_with_settings(settings: &AppSettings) -> Result<Self>
pub async fn open_with_settings(settings: &AppSettings) -> Result<Self>
Open the database described by settings, honoring the
MODDE_DATABASE_* environment overrides used by the Home Manager module.
Sourcepub async fn open_at(path: &Path) -> Result<Self>
pub async fn open_at(path: &Path) -> Result<Self>
Open a SQLite database at a specific path, creating it if needed.
Sourcepub async fn open_memory() -> Result<Self>
pub async fn open_memory() -> Result<Self>
Open an in-memory SQLite database (for testing).
Sourcepub async fn ping(&self) -> Result<()>
pub async fn ping(&self) -> Result<()>
Run the lightest backend-agnostic query available to prove the open connection can execute SQL.
Sourcepub async fn create_profile(&self, profile: &Profile) -> Result<i64>
pub async fn create_profile(&self, profile: &Profile) -> Result<i64>
Create a new profile, returning its database ID.
Sourcepub async fn load_profile(
&self,
name: &str,
game_id: &GameId,
) -> Result<Profile>
pub async fn load_profile( &self, name: &str, game_id: &GameId, ) -> Result<Profile>
Load a profile by name and game_id.
Sourcepub async fn load_profile_by_id(&self, id: i64) -> Result<Profile>
pub async fn load_profile_by_id(&self, id: i64) -> Result<Profile>
Load a profile by its database ID.
Sourcepub async fn load_profile_by_name(&self, name: &str) -> Result<Profile>
pub async fn load_profile_by_name(&self, name: &str) -> Result<Profile>
Load a profile by name only. Errors with AmbiguousProfile if multiple games match.
Sourcepub async fn update_profile(&self, profile: &Profile) -> Result<()>
pub async fn update_profile(&self, profile: &Profile) -> Result<()>
Update an existing profile (identified by name + game_id).
Sourcepub async fn delete_profile(&self, name: &str, game_id: &GameId) -> Result<()>
pub async fn delete_profile(&self, name: &str, game_id: &GameId) -> Result<()>
Delete a profile by name and game_id.
Sourcepub async fn list_profiles(
&self,
game_id: Option<&GameId>,
) -> Result<Vec<ProfileSummary>>
pub async fn list_profiles( &self, game_id: Option<&GameId>, ) -> Result<Vec<ProfileSummary>>
List profile summaries, optionally filtered by game.
Sourcepub async fn assign_save(
&self,
profile_id: i64,
path: &Path,
label: Option<&str>,
) -> Result<()>
pub async fn assign_save( &self, profile_id: i64, path: &Path, label: Option<&str>, ) -> Result<()>
Assign a save to a profile.
Sourcepub async fn unassign_save(&self, path: &Path) -> Result<()>
pub async fn unassign_save(&self, path: &Path) -> Result<()>
Remove a save assignment.
Sourcepub async fn list_saves(&self, profile_id: i64) -> Result<Vec<SaveEntry>>
pub async fn list_saves(&self, profile_id: i64) -> Result<Vec<SaveEntry>>
List all saves assigned to a profile.
Sourcepub async fn is_save_assigned(&self, path: &Path) -> Result<bool>
pub async fn is_save_assigned(&self, path: &Path) -> Result<bool>
Check if a save path is assigned to any profile.
Sourcepub async fn set_active_profile(
&self,
game_id: &GameId,
profile_id: i64,
) -> Result<()>
pub async fn set_active_profile( &self, game_id: &GameId, profile_id: i64, ) -> Result<()>
Set the active profile for a game, replacing any previous one.
Sourcepub async fn get_active_profile(
&self,
game_id: &GameId,
) -> Result<Option<(i64, String)>>
pub async 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 async fn clear_active_profile(&self, game_id: &GameId) -> Result<()>
pub async fn clear_active_profile(&self, game_id: &GameId) -> Result<()>
Clear the active profile for a game.
Sourcepub async fn push_experiment(
&self,
game_id: &GameId,
profile_id: i64,
) -> Result<()>
pub async fn push_experiment( &self, game_id: &GameId, profile_id: i64, ) -> Result<()>
Push a profile onto the experiment stack for a game.
Sourcepub async fn pop_experiment(&self, game_id: &GameId) -> Result<Option<i64>>
pub async fn pop_experiment(&self, game_id: &GameId) -> Result<Option<i64>>
Pop the top entry from the experiment stack, returning the profile_id.
Sourcepub async fn experiment_depth(&self, game_id: &GameId) -> Result<usize>
pub async fn experiment_depth(&self, game_id: &GameId) -> Result<usize>
Get the experiment stack depth for a game.
Sourcepub async fn clear_experiment_stack(&self, game_id: &GameId) -> Result<()>
pub async fn clear_experiment_stack(&self, game_id: &GameId) -> Result<()>
Clear the entire experiment stack for a game.
Sourcepub async fn upsert_snapshot(
&self,
game_id: &GameId,
snapshot_path: &Path,
tree_hash: &str,
file_count: usize,
) -> Result<()>
pub async 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 async fn get_snapshot(
&self,
game_id: &GameId,
) -> Result<Option<SnapshotMeta>>
pub async fn get_snapshot( &self, game_id: &GameId, ) -> Result<Option<SnapshotMeta>>
Get snapshot metadata for a game.
Sourcepub async fn hide_file(
&self,
profile_id: i64,
mod_id: &ModId,
rel_path: &str,
) -> Result<()>
pub async 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 async fn unhide_file(
&self,
profile_id: i64,
mod_id: &ModId,
rel_path: &str,
) -> Result<()>
pub async 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 async fn set_plugin_order(
&self,
profile_id: i64,
plugins: &[PluginEntry],
) -> Result<()>
pub async fn set_plugin_order( &self, profile_id: i64, plugins: &[PluginEntry], ) -> Result<()>
Set the plugin order for a profile (replaces any existing order).
Sourcepub async fn get_plugin_order(
&self,
profile_id: i64,
) -> Result<Vec<PluginEntry>>
pub async fn get_plugin_order( &self, profile_id: i64, ) -> Result<Vec<PluginEntry>>
Get the plugin order for a profile.
Sourcepub async fn toggle_plugin(
&self,
profile_id: i64,
plugin_name: &str,
enabled: bool,
) -> Result<()>
pub async fn toggle_plugin( &self, profile_id: i64, plugin_name: &str, enabled: bool, ) -> Result<()>
Toggle a plugin’s enabled state.
Sourcepub async fn create_category(
&self,
profile_id: i64,
category: &ModCategory,
) -> Result<i64>
pub async fn create_category( &self, profile_id: i64, category: &ModCategory, ) -> Result<i64>
Create a mod category, returning its ID.
Sourcepub async fn update_category(
&self,
category_id: i64,
name: &str,
color: Option<&str>,
sort_index: i64,
) -> Result<()>
pub async fn update_category( &self, category_id: i64, name: &str, color: Option<&str>, sort_index: i64, ) -> Result<()>
Update a category.
Sourcepub async fn delete_category(&self, category_id: i64) -> Result<()>
pub async fn delete_category(&self, category_id: i64) -> Result<()>
Delete a category (nullifies category_id on affected mods).
Sourcepub async fn list_categories(&self, profile_id: i64) -> Result<Vec<ModCategory>>
pub async fn list_categories(&self, profile_id: i64) -> Result<Vec<ModCategory>>
List categories for a profile.
Sourcepub async fn set_mod_category(
&self,
profile_id: i64,
mod_id: &ModId,
category_id: Option<i64>,
) -> Result<()>
pub async fn set_mod_category( &self, profile_id: i64, mod_id: &ModId, category_id: Option<i64>, ) -> Result<()>
Assign a mod to a category.
Sourcepub async fn set_mod_notes(
&self,
profile_id: i64,
mod_id: &ModId,
notes: Option<&str>,
) -> Result<()>
pub async 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 async 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 async 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 async fn record_install(
&self,
profile_id: i64,
mod_id: &ModId,
plan: &InstallPlan,
status: InstallStatus,
) -> Result<()>
pub async fn record_install( &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 (in one transaction).
Sourcepub async fn installed_files_for_mod(
&self,
profile_id: i64,
mod_id: &ModId,
) -> Result<Vec<StagedFile>>
pub async 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 async fn remove_installed_mod(
&self,
profile_id: i64,
mod_id: &ModId,
) -> Result<Vec<StagedFile>>
pub async fn remove_installed_mod( &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. Runs in one transaction.
Sourcepub async fn files_in_merge_group(
&self,
profile_id: i64,
merge_group: &str,
) -> Result<Vec<(String, StagedFile)>>
pub async 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.
Sourcepub async fn import_toml_profiles(&self, profiles_dir: &Path) -> Result<usize>
pub async fn import_toml_profiles(&self, profiles_dir: &Path) -> Result<usize>
Import existing TOML profile files into the database. Returns the number of profiles imported.
Sourcepub async fn save_tool_config(
&self,
game_id: &GameId,
tool_id: &str,
enabled: bool,
settings_json: &str,
) -> Result<()>
pub async 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 async fn save_tool_config_with_reason(
&self,
game_id: &GameId,
tool_id: &str,
enabled: bool,
settings_json: &str,
reason: &str,
) -> Result<()>
pub async 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 async fn list_tool_setting_history(
&self,
game_id: &GameId,
tool_id: &str,
limit: usize,
) -> Result<Vec<ToolSettingHistoryNode>>
pub async 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 async fn list_tool_setting_edges(
&self,
game_id: &GameId,
tool_id: &str,
) -> Result<Vec<ToolSettingHistoryEdge>>
pub async 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 async fn restore_tool_setting_node(
&self,
game_id: &GameId,
tool_id: &str,
node_id: &str,
) -> Result<()>
pub async 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 async fn load_tool_configs(
&self,
game_id: &GameId,
) -> Result<Vec<ToolConfigRow>>
pub async fn load_tool_configs( &self, game_id: &GameId, ) -> Result<Vec<ToolConfigRow>>
Load all tool configurations for a game.
Sourcepub async fn load_tool_config(
&self,
game_id: &GameId,
tool_id: &str,
) -> Result<Option<ToolConfigRow>>
pub async fn load_tool_config( &self, game_id: &GameId, tool_id: &str, ) -> Result<Option<ToolConfigRow>>
Load a single tool configuration for a game.
Sourcepub async fn save_applied_files(
&self,
game_id: &GameId,
tool_id: &str,
rel_paths: &[String],
) -> Result<()>
pub async 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 async fn load_applied_files(
&self,
game_id: &GameId,
tool_id: &str,
) -> Result<Vec<String>>
pub async fn load_applied_files( &self, game_id: &GameId, tool_id: &str, ) -> Result<Vec<String>>
Load files previously applied by a tool.
Sourcepub async fn clear_applied_files(
&self,
game_id: &GameId,
tool_id: &str,
) -> Result<()>
pub async fn clear_applied_files( &self, game_id: &GameId, tool_id: &str, ) -> Result<()>
Clear all applied file records for a tool on a game.
Sourcepub async fn save_executable_config(
&self,
executable: &ExecutableConfigRow,
) -> Result<()>
pub async fn save_executable_config( &self, executable: &ExecutableConfigRow, ) -> Result<()>
Save or update a named executable for a game.
Sourcepub async fn load_executable_configs(
&self,
game_id: &GameId,
) -> Result<Vec<ExecutableConfigRow>>
pub async fn load_executable_configs( &self, game_id: &GameId, ) -> Result<Vec<ExecutableConfigRow>>
Load every executable configured for a game, ordered by display name.
Sourcepub async fn load_executable_config(
&self,
game_id: &GameId,
name: &str,
) -> Result<Option<ExecutableConfigRow>>
pub async fn load_executable_config( &self, game_id: &GameId, name: &str, ) -> Result<Option<ExecutableConfigRow>>
Load a single named executable for a game.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ModdeDb
impl !UnwindSafe for ModdeDb
impl Freeze for ModdeDb
impl Send for ModdeDb
impl Sync for ModdeDb
impl Unpin for ModdeDb
impl UnsafeUnpin for ModdeDb
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more