pub struct ProfileManager { /* private fields */ }Expand description
SQLite-backed profile manager.
Implementations§
Source§impl ProfileManager
impl ProfileManager
Sourcepub fn with_db(db: ModdeDb) -> Self
pub fn with_db(db: ModdeDb) -> Self
Create a profile manager with a custom database (for testing).
Sourcepub fn list(&self) -> Result<Vec<ProfileSummary>>
pub fn list(&self) -> Result<Vec<ProfileSummary>>
List profile summaries, optionally filtered by game.
Sourcepub fn list_for_game(&self, game_id: &GameId) -> Result<Vec<ProfileSummary>>
pub fn list_for_game(&self, game_id: &GameId) -> Result<Vec<ProfileSummary>>
List profiles for a specific game.
Sourcepub fn load(&self, name: &str, game_id: Option<&GameId>) -> Result<Profile>
pub fn load(&self, name: &str, game_id: Option<&GameId>) -> Result<Profile>
Load a profile by name. If game_id is None, the name must be unambiguous.
Sourcepub fn create(&self, profile: &Profile) -> Result<i64>
pub fn create(&self, profile: &Profile) -> Result<i64>
Create a new profile, returning its database ID.
Sourcepub fn create_or_update(&self, profile: &Profile) -> Result<i64>
pub fn create_or_update(&self, profile: &Profile) -> Result<i64>
Create a profile if it doesn’t exist, or update it if it does.
Sourcepub fn delete(&self, name: &str, game_id: Option<&GameId>) -> Result<()>
pub fn delete(&self, name: &str, game_id: Option<&GameId>) -> Result<()>
Delete a profile. If game_id is None, the name must be unambiguous.
Sourcepub fn import_toml(&self, profiles_dir: &Path) -> Result<usize>
pub fn import_toml(&self, profiles_dir: &Path) -> Result<usize>
Import existing TOML profile files into the database.
Sourcepub fn staging_dir(name: &str) -> PathBuf
pub fn staging_dir(name: &str) -> PathBuf
Staging directory for a profile (still on-disk).
Sourcepub fn default_overrides(name: &str) -> PathBuf
pub fn default_overrides(name: &str) -> PathBuf
Default overrides directory for a profile.
Sourcepub fn activate(
&self,
name: &str,
game_id: &GameId,
save_dir: Option<&Path>,
) -> Result<ActivateResult>
pub fn activate( &self, name: &str, game_id: &GameId, save_dir: Option<&Path>, ) -> Result<ActivateResult>
Activate a profile, swapping saves automatically.
save_dir is the game’s save directory (resolved by the caller via
GamePlugin::save_directory()). If None, save swapping is skipped.
fingerprint is the current profile’s mod fingerprint. If provided,
it is embedded in the save vault commit so future restores can warn
about mod mismatches.
If existing saves are detected with no active profile, returns
ActivateResult::AdoptionRequired so the caller can prompt the user.
Sourcepub fn activate_with_fingerprint(
&self,
name: &str,
game_id: &GameId,
save_dir: Option<&Path>,
fingerprint: Option<&SaveFingerprint>,
) -> Result<ActivateResult>
pub fn activate_with_fingerprint( &self, name: &str, game_id: &GameId, save_dir: Option<&Path>, fingerprint: Option<&SaveFingerprint>, ) -> Result<ActivateResult>
Activate with an optional mod fingerprint embedded in the save capture.
Sourcepub fn try_profile(
&self,
name: &str,
game_id: &GameId,
save_dir: Option<&Path>,
) -> Result<()>
pub fn try_profile( &self, name: &str, game_id: &GameId, save_dir: Option<&Path>, ) -> Result<()>
Try a profile experimentally, pushing the current profile onto the stack.
save_dir is the game’s save directory. If None, save swapping is skipped.
fingerprint is the current profile’s mod fingerprint.
Sourcepub fn try_profile_with_fingerprint(
&self,
name: &str,
game_id: &GameId,
save_dir: Option<&Path>,
fingerprint: Option<&SaveFingerprint>,
) -> Result<()>
pub fn try_profile_with_fingerprint( &self, name: &str, game_id: &GameId, save_dir: Option<&Path>, fingerprint: Option<&SaveFingerprint>, ) -> Result<()>
Try a profile experimentally with a mod fingerprint.
Sourcepub fn rollback(
&self,
game_id: &GameId,
save_dir: Option<&Path>,
) -> Result<String>
pub fn rollback( &self, game_id: &GameId, save_dir: Option<&Path>, ) -> Result<String>
Roll back to the previous profile on the experiment stack. Returns the name of the profile we rolled back to.
save_dir is the game’s save directory. If None, save swapping is skipped.
fingerprint is the current profile’s mod fingerprint.
Sourcepub fn rollback_with_fingerprint(
&self,
game_id: &GameId,
save_dir: Option<&Path>,
fingerprint: Option<&SaveFingerprint>,
) -> Result<String>
pub fn rollback_with_fingerprint( &self, game_id: &GameId, save_dir: Option<&Path>, fingerprint: Option<&SaveFingerprint>, ) -> Result<String>
Roll back with a mod fingerprint.
Sourcepub fn commit(&self, game_id: &GameId) -> Result<()>
pub fn commit(&self, game_id: &GameId) -> Result<()>
Accept the current experiment, clearing the experiment stack.
Sourcepub fn active(&self, game_id: &GameId) -> Result<Option<ActiveProfileInfo>>
pub fn active(&self, game_id: &GameId) -> Result<Option<ActiveProfileInfo>>
Get the currently active profile and experiment depth for a game.
Sourcepub fn fork(
&self,
source_name: &str,
new_name: &str,
game_id: &GameId,
) -> Result<i64>
pub fn fork( &self, source_name: &str, new_name: &str, game_id: &GameId, ) -> Result<i64>
Fork a profile: clone its mods, load order rules, and save branch.
By default this is a faithful copy — both the profile-level
load_order_lock and every per-mod pin ride along. Use
Self::fork_with_options (or modde profile fork --unlock) for
the “fork to diverge” workflow where the new profile starts
unlocked so it can be freely reorganised.
Sourcepub fn fork_with_options(
&self,
source_name: &str,
new_name: &str,
game_id: &GameId,
options: ForkOptions,
) -> Result<i64>
pub fn fork_with_options( &self, source_name: &str, new_name: &str, game_id: &GameId, options: ForkOptions, ) -> Result<i64>
Fork a profile with explicit control over whether the new profile
inherits locks. See ForkOptions for the flags.