Skip to main content

Module single_instance

Module single_instance 

Source
Expand description

Standalone single instance with a typed message, usable without the shell plugin.

SingleInstance::claim makes this process the app’s primary, or forwards this launch’s InstanceMessage (argv, cwd, an optional action and a JSON argument map) to the live primary and reports that it did. The outcome is typed and fail-closed:

  • ClaimOutcome::Primary: this process is the primary. Keep the guard for the process lifetime.
  • ClaimOutcome::Forwarded: a live primary accepted the message. The caller must exit.
  • ClaimOutcome::Failed: arbitration could not be decided. The caller must not continue as a second primary; it should report the reason and exit.

Arbitration runs over rightkit-daemon (current-user socket or named pipe, a probed endpoint and a live pid), so a crashed primary never blocks the next launch. The shell plugin’s own arbitration (instance, method second-instance) is separate; an app uses one or the other.

Reference: Pulse hub’s win_bridge::claim_instance (a named mutex that forwards --section). That path fails open when the singleton cannot be secured; this one fails closed.

Structs§

ClaimOptions
Options for SingleInstance::claim_with_options.
InstanceMessage
The payload one launch hands to the primary.
LegacySingleInstanceNames
Every name tauri-plugin-single-instance 2.x derives from the Tauri identifier (tauri.conf.json identifier). Read from plugin versions 2.4.2 and 2.4.3 (src/platform_impl/{windows,macos,linux}.rs), with the plugin’s semver feature off. HeardRight confirmed the names at its locked 2.4.5 (verified by the consumer; 2.4.5 source was not read here). The derivation is pure, so it is the same on every host.
SingleInstance
Standalone single-instance arbitration.
SingleInstanceGuard
Holds one primary claim. Dropping it releases the claim, the same as [destroy] does for all.

Enums§

ClaimFailure
Why arbitration could not be decided. Each variant carries the underlying message.
ClaimOutcome
The typed result of SingleInstance::claim.

Constants§

MESSAGE_METHOD
Service method a forwarded launch calls on the primary.