Skip to main content

Module open_url

Module open_url 

Source
Expand description

Standalone “open URL” hook: usable without the full Shell plugin.

One process-wide hub receives every URL the OS hands the app and fans it out to handlers:

URLs that arrive before any handler is registered (cold start) are buffered and readable with current_urls; on_open_url handlers receive URLs that arrive after registration. The same URL delivered twice within DEDUP_WINDOW (for example argv and an Apple Event for one click) reaches handlers once.

Scheme registration (mailto:, custom schemes) stays with the app’s installer or bundle (CFBundleURLTypes, NSIS/MSI protocol entries, .desktop MIME types). This module only delivers what the OS already routed to the process. The full Shell plugin feeds the same hub, so handlers registered here also see its deliveries.

Structs§

UrlHub
Queue, de-dup and dispatch logic with an injectable clock. hub owns the process-wide one.

Constants§

DEDUP_WINDOW
The same URL seen again inside this window is a duplicate delivery.

Functions§

capture_launch_args
Deliver the URLs on this process’s command line (Windows/Linux cold start). Call once, early.
current_urls
URLs that arrived before the first on_open_url handler was registered (cold start).
deliver
Deliver URLs from any source the app owns (for example a custom IPC). Returns how many were new.
deliver_second_instance
Deliver the URLs on a second launch’s argv (argv[0] is the executable and is skipped).
handle_run_event
Feed Apple Event URLs from the Tauri run loop: call it for every event in app.run(|_, event| rightkit_tauri_shell::open_url::handle_run_event(&event)). A no-op elsewhere.
hub
The process-wide hub.
init_single_instance
Single-instance arbitration wired to this hub, with no Shell plugin. The primary process captures its own launch URLs; a second launch forwards its argv to the primary and the caller must exit on Arbitration::Secondary. Keep the Primary guard alive for the process lifetime.
is_url
True for scheme:rest where the scheme is at least two characters, so Windows drive paths such as C:\mail are not URLs. Control characters and over-long input are rejected.
on_open_url
Register a handler for URLs the OS opens in this app from now on.
urls_from_args
The URL-shaped entries of a command line (flags, paths and drive letters are skipped).

Type Aliases§

UrlHandler
Receives a batch of URLs that arrived together.