pub enum ClaimFailure {
Discovery(String),
Host(String),
Forward(String),
Legacy(String),
InvalidId(String),
}Expand description
Why arbitration could not be decided. Each variant carries the underlying message.
Every variant is fail-closed: SingleInstance::claim never turns one into a second primary on
its own. A user must still never be locked out of launching the app, so the app decides what
happens next, and the crate bounds how long each step can take so that decision is reached quickly:
- a live-primary forward retries the connect for at most 2 s (20 attempts, 100 ms apart) and sends once;
- a legacy forward waits at most 5 s for the old holder to answer (Windows
SendMessageTimeoutWwith abort-if-hung; macOS a 5 s write timeout, then 2 s for the holder to close the connection it was written to, seeClaimOutcome::Forwarded); - hosting the claim waits at most 5 s for an election;
- so one
claimcall returns within about 14 s in the worst case.
The crate enforces those bounds; the app enforces the rest (below). An app should show or log the reason, and on a variant it cannot recover from, start anyway after at most that bound rather than exit silently, unless a second copy would corrupt data, in which case it should tell the user why it will not start and how to end the other copy.
Variants§
Discovery(String)
The suite root (the per-user service directory) could not be resolved. Nothing was hosted, so no other copy can have been told about this launch. Safe to log and continue unarbitrated.
Host(String)
The primary endpoint could not be hosted, for a reason other than a live primary. Usually a permissions or disk problem. Continue unarbitrated only if duplicates are harmless; otherwise report it.
Forward(String)
A live primary exists, but it could not be reached or did not accept the message within the bound above (hung, or mid-shutdown). Do not start a second primary silently: tell the user the running copy is not responding, and offer to retry. A retry after the bound is safe.
Legacy(String)
A live instance started by tauri-plugin-single-instance holds the claim and could not take
this launch within the bound (a hung old build). The caller must not start a second primary
silently; report that the older copy is not responding and how to close it.
InvalidId(String)
The id cannot be turned into a service name (empty, or longer than 39 bytes). The id is
normalised first (ASCII lowercase, every character outside [a-z0-9-] becomes -), so a
dotted bundle identifier is fine. This is a caller bug: nothing was hosted and protection is
off, so fix the id rather than continuing unarbitrated.
Trait Implementations§
Source§impl Clone for ClaimFailure
impl Clone for ClaimFailure
Source§impl Debug for ClaimFailure
impl Debug for ClaimFailure
Source§impl Display for ClaimFailure
impl Display for ClaimFailure
impl Eq for ClaimFailure
Source§impl Error for ClaimFailure
impl Error for ClaimFailure
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl PartialEq for ClaimFailure
impl PartialEq for ClaimFailure
impl StructuralPartialEq for ClaimFailure
Auto Trait Implementations§
impl Freeze for ClaimFailure
impl RefUnwindSafe for ClaimFailure
impl Send for ClaimFailure
impl Sync for ClaimFailure
impl Unpin for ClaimFailure
impl UnsafeUnpin for ClaimFailure
impl UnwindSafe for ClaimFailure
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.