Skip to main content

ProfileManager

Struct ProfileManager 

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

SQLite-backed profile manager.

Implementations§

Source§

impl ProfileManager

Source

pub fn open() -> Result<Self>

Open the profile manager using the default database path.

Source

pub fn with_db(db: ModdeDb) -> Self

Create a profile manager with a custom database (for testing).

Source

pub fn db(&self) -> &ModdeDb

Access the underlying database.

Source

pub fn list(&self) -> Result<Vec<ProfileSummary>>

List profile summaries, optionally filtered by game.

Source

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

List profiles for a specific game.

Source

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.

Source

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

Create a new profile, returning its database ID.

Source

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

Update an existing profile.

Source

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

Create a profile if it doesn’t exist, or update it if it does.

Source

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

Delete a profile. If game_id is None, the name must be unambiguous.

Source

pub fn import_toml(&self, profiles_dir: &Path) -> Result<usize>

Import existing TOML profile files into the database.

Source

pub fn staging_dir(name: &str) -> PathBuf

Staging directory for a profile (still on-disk).

Source

pub fn default_overrides(name: &str) -> PathBuf

Default overrides directory for a profile.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn rollback_with_fingerprint( &self, game_id: &GameId, save_dir: Option<&Path>, fingerprint: Option<&SaveFingerprint>, ) -> Result<String>

Roll back with a mod fingerprint.

Source

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

Accept the current experiment, clearing the experiment stack.

Source

pub fn active(&self, game_id: &GameId) -> Result<Option<ActiveProfileInfo>>

Get the currently active profile and experiment depth for a game.

Source

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.

Source

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.

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