Skip to main content

Module links

Module links 

Source
Expand description

Links’ pure parts (ADR 0017): a target parsed and classified, the request to open it, and the one policy deciding how it opens and whether the user confirms first. No egui and no system call: the service, the openers, the widget and the confirmation are egui_pop_api::links’.

Experimental: may change in any release (docs/stability.md).
  • A target (Target) is a URL (https:, mailto:, file:, docs:, command:, the application’s own scheme) or an absolute local path, parsed once; its host is kept in punycode and shown in Unicode.
  • A request (Request) names the target, how (How: Auto, Outside, Inside, Reveal), its source (Source: declared by the application, found in content, asked by an agent), the text it was shown under, and who asks.
  • The policy (Policy::decide) classifies the target (Kind), resolves Auto against what the opener can do (Caps) and says whether to confirm, or why it is refused.
use egui_pop_model::links::{Caps, Facts, How, Kind, Policy, Request, Source};

let policy = Policy::default();
let about = Request::new("https://github.com/quazardous/egui-pop");
let d = policy.decide(&about, &Caps::ALL, None);
assert_eq!((d.kind, d.how, d.confirm), (Kind::Web, How::Outside, false));

// The same page found in a document asks first, until its host is
// trusted for the session.
let found = about.clone().source(Source::Content);
assert!(policy.decide(&found, &Caps::ALL, None).confirm);

// A local executable is never opened: Reveal is offered instead.
let tool = Request::new("/opt/tool/run.sh");
let d = policy.decide(&tool, &Caps::ALL, Some(&Facts::file()));
assert!(d.refused.is_some() && d.reveal_instead);

Modules§

inline
The inline subset for short texts (ADR 0017): tips, toasts and settings descriptions may carry emphasis, code and links without a markdown renderer. A text is cut into Runs, each drawn as it says; nothing else of markdown is read (no headings, lists, images or HTML: they stay as they are written).

Structs§

Caps
What the opener can do here.
Decision
What the policy decided.
Facts
What is known of a local target, read by the caller (the policy never touches the disk).
Found
A link found in a short text: its label (a markdown link’s) and its target.
Policy
The rules links follow: the schemes allowed, the hosts trusted for the session, the hosts holding the application’s documentation, the application’s own scheme.
Request
A request to open a link.
Target
A parsed target.

Enums§

How
How a link opens.
Kind
What a target is, from its scheme, host and extension (never by fetching it).
Reason
Why a link is refused.
Source
Where a link comes from: what the policy trusts.

Constants§

EXECUTABLE
Extensions of programs and scripts: never opened from a link.
SCHEMES
The schemes allowed by default.
VIDEOS
The extensions of video files, in lower case.
VIDEO_HOSTS
Hosts whose pages are videos (a link there never shows inside).

Functions§

check_declared
What is wrong with a link the application declares: it must parse, use an allowed scheme, and a command: link must name a declared command (commands). docs lists the docs: pages the application ships, when it says (None: not checked).
disguised
Whether a link’s text looks like an address other than its target’s (another host, or another page on it).
find
The links in a short text: markdown links ([label](target)), autolinks (<https://…>) and bare http(s):// addresses.
looks_like_url
Whether a text looks like an address (https://…, www.…, example.org/…, mailto:…): a link shown under such a text must go there, or it is confirmed with both shown.
percent_decode
Decodes %xx sequences (invalid ones are kept as they are).