Skip to main content

Store

Struct Store 

Source
pub struct Store { /* private fields */ }

Implementations§

Source§

impl Store

Source

pub fn open(paths: &Paths) -> Result<Store>

Source

pub fn lock(&self) -> Result<LockGuard, LockError>

Exclusive lock around the read-current -> backup -> apply compound; refuse (rather than block) if another swapdex is mid-switch.

Source

pub fn lock_tool(&self, tool: &str) -> Result<LockGuard, LockError>

A per-tool credential lock, distinct from the whole-store lock. login holds it across its interactive sign-in - during which the store lock is deliberately RELEASED so unrelated swapdex ops proceed - and use/restore take it for the tools they switch. So a concurrent switch can never interleave with a sign-in on the SAME tool (the credential-race the store lock alone can’t prevent once it is released for the wait). It try-locks: a caller fails fast with Busy rather than blocking.

Source

pub fn save(&self, name: &str, snap: &Snapshot) -> Result<()>

Source

pub fn load(&self, name: &str, tool: &str) -> Result<Option<Snapshot>>

Source

pub fn list(&self) -> Vec<ProfileInfo>

Source

pub fn remove(&self, name: &str) -> Result<bool>

Source

pub fn drop_tool(&self, name: &str, tool: &str) -> Result<bool>

Rename a profile. Returns false if old does not exist; errors if new already exists. Drop ONE tool from a profile, leaving the rest of it alone.

add defaults to every tool, so signing into one sweeps in whatever else happens to be logged in - and until now there was no way to take one back out short of deleting the whole profile. A profile ended up carrying Gemini and Antigravity logins its owner never asked swapdex to manage, which then went stale and nagged about tools he does not use.

Returns false when that profile has no such tool: asking to remove something already absent is the outcome the caller wanted, not an error.

Source

pub fn profile_dir_exists(&self, name: &str) -> bool

Whether ANY directory (even a ghost one hidden from list()) claims this name - the collision test for rename targets.

Source

pub fn rename(&self, old: &str, new: &str) -> Result<bool>

Source

pub fn backup(&self, snap: &Snapshot) -> Result<()>

Back up a live snapshot before a switch; keep only the newest 2 per tool.

Source

pub fn load_backup(&self, tool: &str) -> Result<Option<(u128, Snapshot)>>

The newest backup snapshot for a tool (taken by use before each switch), with its unix-nanos stamp. None when no backup exists.

Source

pub fn append_timeline( &self, tool: &str, account: &str, action: &str, ) -> Result<()>

Source

pub fn append_timeline_at( &self, tool: &str, account: &str, action: &str, ts: u64, ) -> Result<()>

Append with an explicit timestamp so every tool touched by ONE use / restore invocation shares the same ts - that shared ts is what lets a bare restore scope itself to exactly the last switch.

Source

pub fn append_timeline_inv( &self, tool: &str, account: &str, action: &str, ts: u64, inv: u128, ) -> Result<()>

inv is a per-INVOCATION discriminator (nanos): whole-second ts alone collides when two separate invocations run inside one second, and bare restore scopes to “the last invocation’s tools” by it. 0 = legacy/unknown (grouping falls back to ts equality).

Auto Trait Implementations§

§

impl Freeze for Store

§

impl RefUnwindSafe for Store

§

impl Send for Store

§

impl Sync for Store

§

impl Unpin for Store

§

impl UnsafeUnpin for Store

§

impl UnwindSafe for Store

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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 = !

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.