Skip to main content

ProfileStore

Struct ProfileStore 

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

Manager for profile storage operations.

Root storage shape:

  • {base_dir}/auth.json
  • {base_dir}/profiles.json
  • {base_dir}/keys.json
  • {base_dir}/threads/

Implementations§

Source§

impl ProfileStore

Source

pub fn new() -> Result<Self>

Create a new profile store.

Uses the OS-appropriate config directory:

  • Linux: ~/.config/squigit/
  • macOS: ~/Library/Application Support/squigit/
  • Windows: %APPDATA%/squigit/
Source

pub fn with_base_dir(base_dir: PathBuf) -> Result<Self>

Create a profile store using an explicit base directory.

This is primarily intended for tests and future CLI integration.

Source

pub fn base_dir(&self) -> &PathBuf

Get the base storage directory path.

Source

pub fn get_profile_dir(&self, profile_id: &str) -> PathBuf

Get the directory path for a specific profile.

Returns {base_dir}/{profile_id}/

Source

pub fn with_key_store_transaction<T, E>( &self, operation: impl FnOnce(&KeyStoreTransaction<'_>) -> Result<T, E>, ) -> Result<T, E>
where E: From<StorageError>,

Source

pub fn load_encrypted_key_record( &self, profile_id: &str, provider_key: &str, ) -> Result<Option<EncryptedKeyRecord>>

Source

pub fn update_last_trusted_reveal(&self) -> Result<()>

Source

pub fn invalidate_last_trusted_reveal(&self) -> Result<()>

Source

pub fn get_last_trusted_reveal(&self) -> Result<Option<DateTime<Utc>>>

Source

pub fn get_key_width( &self, profile_id: &str, provider_key: &str, ) -> Result<Option<u32>>

Source

pub fn delete_profile_key_records(&self, profile_id: &str) -> Result<bool>

Delete all encrypted key records for a profile.

Source

pub fn get_active_profile_id(&self) -> Result<Option<String>>

Get the ID of the currently active profile.

Source

pub fn set_active_profile_id(&self, profile_id: &str) -> Result<()>

Set the active profile by ID.

Returns an error if the profile doesn’t exist.

Source

pub fn record_last_login(&self, last_login: LastLogin) -> Result<()>

Record a successful provider login and activate the authenticated profile.

Source

pub fn clear_active_profile_id(&self) -> Result<()>

Clear the active profile (for Guest mode logout).

Source

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

Create or update a profile.

If the profile already exists, it will be updated with the new data. Profile metadata is stored in the root profiles.json file.

Source

pub fn get_profile(&self, profile_id: &str) -> Result<Option<Profile>>

Get a profile by ID.

Source

pub fn get_active_profile(&self) -> Result<Option<Profile>>

Get the currently active profile.

Source

pub fn profile_snapshot(&self) -> Result<ProfileSnapshot>

Load active account state and all profiles from root files.

Source

pub fn delete_profile(&self, profile_id: &str) -> Result<()>

Delete a profile and all its data.

Returns an error if trying to delete the last profile.

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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.