Skip to main content

open_uri

Function open_uri 

pub fn open_uri(uri: &str) -> Result<(), Error>
Expand description

Hand a URI (a web page, a mailto: draft, a settings: pane) to the current host’s crate::UriOpener.

On the native desktop, Unix builds with the portal feature go through the XDG OpenURI portal: inside the app sandbox there is no host xdg-open to spawn, and the portal is where the desktop applies its own handler choice and policy. Other native builds use the platform opener (ShellExecute on Windows).

Blocks until the handler is launched or the request is refused, so call it from a worker thread; open_uri_detached is the fire-and-forget form.

§Errors

Returns invalid input for a URI containing NUL (which native APIs would otherwise silently truncate), and the host’s error when it cannot parse or refuses the request.