Skip to main content

ModdeDb

Struct ModdeDb 

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

SQLite-backed persistent storage for modde.

Implementations§

Source§

impl ModdeDb

Source

pub fn open() -> Result<Self>

Open the database at the default XDG path, creating it if needed.

Source

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

Open the database at a specific path (useful for testing).

Source

pub fn open_memory() -> Result<Self>

Open an in-memory database (for testing).

Source

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

Create a new profile, returning its database ID.

Source

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

Load a profile by name and game_id.

Source

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

Load a profile by its database ID.

Source

pub 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 fn update_profile(&self, profile: &Profile) -> Result<()>

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

Source

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

Delete a profile by name and game_id.

Source

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

List profile summaries, optionally filtered by game.

Source

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

Assign a save to a profile.

Source

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

Remove a save assignment.

Source

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

List all saves assigned to a profile.

Source

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

Check if a save path is assigned to any profile.

Source

pub 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 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 fn clear_active_profile(&self, game_id: &GameId) -> Result<()>

Clear the active profile for a game.

Source

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

Push a profile onto the experiment stack for a game.

Source

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

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

Source

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

Get the experiment stack depth for a game.

Source

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

Clear the entire experiment stack for a game.

Source

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.

Source

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

Get snapshot metadata for a game.

Source

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

Source

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

Unhide a previously hidden file.

Source

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

List all hidden files for a profile.

Source

pub 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 fn set_plugin_order( &self, profile_id: i64, plugins: &[PluginEntry], ) -> Result<()>

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

Source

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

Get the plugin order for a profile.

Source

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

Toggle a plugin’s enabled state.

Source

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

Create a mod category, returning its ID.

Source

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

Update a category.

Source

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

Delete a category (nullifies category_id on affected mods).

Source

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

List categories for a profile.

Source

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

Assign a mod to a category.

Source

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

Set notes for a mod.

Source

pub 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 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 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:

  1. Write the encoded install_method, source_archive_hash, and install_status back to profile_mods.
  2. Wipe any previous installed_mod_files rows for this mod (so retries don’t leave orphans in the manifest).
  3. 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.

Source

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.

Source

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.

Source

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.

Source

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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Load all tool configurations for a game.

Source

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

Load a single tool configuration for a game.

Source

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.

Source

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

Load files previously applied by a tool.

Source

pub 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 fn save_executable_config( &self, executable: &ExecutableConfigRow, ) -> Result<()>

Save or update a named executable for a game.

Source

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

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

Source

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

Load a single named executable for a game.

Source

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

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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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: 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, 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<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