Skip to main content

ClaimFailure

Enum ClaimFailure 

Source
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 SendMessageTimeoutW with abort-if-hung; macOS a 5 s write timeout, then 2 s for the holder to close the connection it was written to, see ClaimOutcome::Forwarded);
  • hosting the claim waits at most 5 s for an election;
  • so one claim call 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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ClaimFailure

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ClaimFailure

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ClaimFailure

Source§

impl Error for ClaimFailure

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl PartialEq for ClaimFailure

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ClaimFailure

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.
Source§

impl<T> UserEvent for T
where T: Debug + Clone + Send + 'static,