Skip to main content

ModdeDb

Struct ModdeDb 

Source
pub struct ModdeDb { /* private fields */ }
Expand description

SQLite/PostgreSQL-backed persistent storage for modde.

Implementations§

Source§

impl ModdeDb

Source

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.

Source

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.

Source

pub async fn open_at(path: &Path) -> Result<Self>

Open a SQLite database at a specific path, creating it if needed.

Source

pub async fn open_memory() -> Result<Self>

Open an in-memory SQLite database (for testing).

Source

pub async fn ping(&self) -> Result<()>

Run the lightest backend-agnostic query available to prove the open connection can execute SQL.

Source

pub async fn create_profile(&self, profile: &Profile) -> Result<i64>

Create a new profile, returning its database ID.

Source

pub async fn load_profile( &self, name: &str, game_id: &GameId, ) -> Result<Profile>

Load a profile by name and game_id.

Source

pub async fn load_profile_by_id(&self, id: i64) -> Result<Profile>

Load a profile by its database ID.

Source

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.

Source

pub async fn update_profile(&self, profile: &Profile) -> Result<()>

Update an existing profile (identified by name + game_id).

Source

pub async fn delete_profile(&self, name: &str, game_id: &GameId) -> Result<()>

Delete a profile by name and game_id.

Source

pub async fn list_profiles( &self, game_id: Option<&GameId>, ) -> Result<Vec<ProfileSummary>>

List profile summaries, optionally filtered by game.

Source

pub async fn assign_save( &self, profile_id: i64, path: &Path, label: Option<&str>, ) -> Result<()>

Assign a save to a profile.

Source

pub async fn unassign_save(&self, path: &Path) -> Result<()>

Remove a save assignment.

Source

pub async fn list_saves(&self, profile_id: i64) -> Result<Vec<SaveEntry>>

List all saves assigned to a profile.

Source

pub async fn is_save_assigned(&self, path: &Path) -> Result<bool>

Check if a save path is assigned to any profile.

Source

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.

Source

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).

Source

pub async fn clear_active_profile(&self, game_id: &GameId) -> Result<()>

Clear the active profile for a game.

Source

pub async fn push_experiment( &self, game_id: &GameId, profile_id: i64, ) -> Result<()>

Push a profile onto the experiment stack for a game.

Source

pub async fn pop_experiment(&self, game_id: &GameId) -> Result<Option<i64>>

Pop the top entry from the experiment stack, returning the profile_id.

Source

pub async fn experiment_depth(&self, game_id: &GameId) -> Result<usize>

Get the experiment stack depth for a game.

Source

pub async fn clear_experiment_stack(&self, game_id: &GameId) -> Result<()>

Clear the entire experiment stack for a game.

Source

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.

Source

pub async fn get_snapshot( &self, game_id: &GameId, ) -> Result<Option<SnapshotMeta>>

Get snapshot metadata for a game.

Source

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).

Source

pub async fn unhide_file( &self, profile_id: i64, mod_id: &ModId, rel_path: &str, ) -> Result<()>

Unhide a previously hidden file.

Source

pub async fn list_hidden_files( &self, profile_id: i64, ) -> Result<Vec<HiddenFile>>

List all hidden files for a profile.

Source

pub async fn list_hidden_files_for_mod( &self, profile_id: i64, mod_id: &ModId, ) -> Result<Vec<String>>

List hidden files for a specific mod in a profile.

Source

pub async fn set_plugin_order( &self, profile_id: i64, plugins: &[PluginEntry], ) -> Result<()>

Set the plugin order for a profile (replaces any existing order).

Source

pub async fn get_plugin_order( &self, profile_id: i64, ) -> Result<Vec<PluginEntry>>

Get the plugin order for a profile.

Source

pub async fn toggle_plugin( &self, profile_id: i64, plugin_name: &str, enabled: bool, ) -> Result<()>

Toggle a plugin’s enabled state.

Source

pub async fn create_category( &self, profile_id: i64, category: &ModCategory, ) -> Result<i64>

Create a mod category, returning its ID.

Source

pub async fn update_category( &self, category_id: i64, name: &str, color: Option<&str>, sort_index: i64, ) -> Result<()>

Update a category.

Source

pub async fn delete_category(&self, category_id: i64) -> Result<()>

Delete a category (nullifies category_id on affected mods).

Source

pub async fn list_categories(&self, profile_id: i64) -> Result<Vec<ModCategory>>

List categories for a profile.

Source

pub async fn set_mod_category( &self, profile_id: i64, mod_id: &ModId, category_id: Option<i64>, ) -> Result<()>

Assign a mod to a category.

Source

pub async fn set_mod_notes( &self, profile_id: i64, mod_id: &ModId, notes: Option<&str>, ) -> Result<()>

Set notes for a mod.

Source

pub async fn set_mod_tags( &self, profile_id: i64, mod_id: &ModId, tags: &[String], ) -> Result<()>

Set tags for a mod (stored as a JSON array in the TEXT column).

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub async fn load_tool_configs( &self, game_id: &GameId, ) -> Result<Vec<ToolConfigRow>>

Load all tool configurations for a game.

Source

pub async fn load_tool_config( &self, game_id: &GameId, tool_id: &str, ) -> Result<Option<ToolConfigRow>>

Load a single tool configuration for a game.

Source

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.

Source

pub async fn load_applied_files( &self, game_id: &GameId, tool_id: &str, ) -> Result<Vec<String>>

Load files previously applied by a tool.

Source

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.

Source

pub async fn save_executable_config( &self, executable: &ExecutableConfigRow, ) -> Result<()>

Save or update a named executable for a game.

Source

pub async fn load_executable_configs( &self, game_id: &GameId, ) -> Result<Vec<ExecutableConfigRow>>

Load every executable configured for a game, ordered by display name.

Source

pub async fn load_executable_config( &self, game_id: &GameId, name: &str, ) -> Result<Option<ExecutableConfigRow>>

Load a single named executable for a game.

Source

pub async fn delete_executable_config( &self, game_id: &GameId, name: &str, ) -> Result<bool>

Delete a named executable for a game. Returns whether a row was removed.

Trait Implementations§

Source§

impl Clone for ModdeDb

Source§

fn clone(&self) -> ModdeDb

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ModdeDb

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more