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
impl ProfileStore
Sourcepub fn new() -> Result<Self>
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/
Sourcepub fn with_base_dir(base_dir: PathBuf) -> Result<Self>
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.
Sourcepub fn get_profile_dir(&self, profile_id: &str) -> PathBuf
pub fn get_profile_dir(&self, profile_id: &str) -> PathBuf
Get the directory path for a specific profile.
Returns {base_dir}/{profile_id}/
pub fn with_key_store_transaction<T, E>(
&self,
operation: impl FnOnce(&KeyStoreTransaction<'_>) -> Result<T, E>,
) -> Result<T, E>where
E: From<StorageError>,
pub fn load_encrypted_key_record( &self, profile_id: &str, provider_key: &str, ) -> Result<Option<EncryptedKeyRecord>>
pub fn update_last_trusted_reveal(&self) -> Result<()>
pub fn invalidate_last_trusted_reveal(&self) -> Result<()>
pub fn get_last_trusted_reveal(&self) -> Result<Option<DateTime<Utc>>>
pub fn get_key_width( &self, profile_id: &str, provider_key: &str, ) -> Result<Option<u32>>
Sourcepub fn delete_profile_key_records(&self, profile_id: &str) -> Result<bool>
pub fn delete_profile_key_records(&self, profile_id: &str) -> Result<bool>
Delete all encrypted key records for a profile.
Sourcepub fn get_active_profile_id(&self) -> Result<Option<String>>
pub fn get_active_profile_id(&self) -> Result<Option<String>>
Get the ID of the currently active profile.
Sourcepub fn set_active_profile_id(&self, profile_id: &str) -> Result<()>
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.
Sourcepub fn record_last_login(&self, last_login: LastLogin) -> Result<()>
pub fn record_last_login(&self, last_login: LastLogin) -> Result<()>
Record a successful provider login and activate the authenticated profile.
Sourcepub fn clear_active_profile_id(&self) -> Result<()>
pub fn clear_active_profile_id(&self) -> Result<()>
Clear the active profile (for Guest mode logout).
Sourcepub fn upsert_profile(&self, profile: &Profile) -> Result<()>
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.
Sourcepub fn get_active_profile(&self) -> Result<Option<Profile>>
pub fn get_active_profile(&self) -> Result<Option<Profile>>
Get the currently active profile.
Sourcepub fn profile_snapshot(&self) -> Result<ProfileSnapshot>
pub fn profile_snapshot(&self) -> Result<ProfileSnapshot>
Load active account state and all profiles from root files.
Sourcepub fn delete_profile(&self, profile_id: &str) -> Result<()>
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.