Trait ExternalUrlOpener

Source
pub trait ExternalUrlOpener {
    // Required method
    fn open(&self, url: &ExternalUrl) -> Result<(), OpenUrlError>;
}
Expand description

Provider-neutral capability used by widgets to open validated URLs.

Implementations should return promptly, must not shell-interpolate the URL, and should avoid logging its potentially sensitive exact source.

§Examples

use ailloli_ui_runtime::app::{ExternalUrl, ExternalUrlOpener, MemoryExternalUrlOpener};
let opener: &dyn ExternalUrlOpener = &MemoryExternalUrlOpener::new();
let url = ExternalUrl::parse("https://example.com")?;
opener.open(&url)?;

Required Methods§

Source

fn open(&self, url: &ExternalUrl) -> Result<(), OpenUrlError>

Hands one already validated URL to the host.

A successful return means the host accepted the request, not that a browser loaded the resource.

§Errors

Returns OpenUrlError::Unavailable when no host capability can accept the URL, or OpenUrlError::LaunchFailed when an available capability fails to launch it.

§Examples
use ailloli_ui_runtime::app::{ExternalUrl, ExternalUrlOpener, MemoryExternalUrlOpener};
let opener = MemoryExternalUrlOpener::new();
let url = ExternalUrl::parse("https://example.com")?;
assert_eq!(opener.open(&url), Ok(()));
assert_eq!(opener.opened_urls(), ["https://example.com"]);

Implementors§

Source§

impl ExternalUrlOpener for MemoryExternalUrlOpener

Implements the ExternalUrlOpener contract for MemoryExternalUrlOpener.