pub struct Store { /* private fields */ }Implementations§
Source§impl Store
impl Store
pub fn open(paths: &Paths) -> Result<Store>
Sourcepub fn lock(&self) -> Result<LockGuard, LockError>
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.
Sourcepub fn lock_tool(&self, tool: &str) -> Result<LockGuard, LockError>
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.
pub fn save(&self, name: &str, snap: &Snapshot) -> Result<()>
pub fn load(&self, name: &str, tool: &str) -> Result<Option<Snapshot>>
pub fn list(&self) -> Vec<ProfileInfo>
pub fn remove(&self, name: &str) -> Result<bool>
Sourcepub fn drop_tool(&self, name: &str, tool: &str) -> Result<bool>
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.
Sourcepub fn profile_dir_exists(&self, name: &str) -> bool
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.
pub fn rename(&self, old: &str, new: &str) -> Result<bool>
Sourcepub fn backup(&self, snap: &Snapshot) -> Result<()>
pub fn backup(&self, snap: &Snapshot) -> Result<()>
Back up a live snapshot before a switch; keep only the newest 2 per tool.
Sourcepub fn load_backup(&self, tool: &str) -> Result<Option<(u128, Snapshot)>>
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.
pub fn append_timeline( &self, tool: &str, account: &str, action: &str, ) -> Result<()>
Sourcepub fn append_timeline_at(
&self,
tool: &str,
account: &str,
action: &str,
ts: u64,
) -> Result<()>
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.
Sourcepub fn append_timeline_inv(
&self,
tool: &str,
account: &str,
action: &str,
ts: u64,
inv: u128,
) -> Result<()>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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