Skip to main content

Module links

Module links 

Source
Expand description

Links (ADR 0017): one service opens them, through one policy and one step, with a replaceable opener.

Experimental: may change in any release (docs/stability.md).
  • Requests (Request, from egui_pop_model::links) name the target, how (Auto, Outside, Inside, Reveal), the source (declared by the application, found in content, asked by an agent), the text the link was shown under and who asks. open runs them through the link.open step: a before-hook vetoes or redirects, a run-hook opens its own way, the journal says link.opened, link.failed, link.asked or link.cancelled.
  • The policy (Policy) classifies the target and decides how it opens and whether the user confirms first: declared web and mail links open at once; a content link asks while its host is not trusted (the confirmation offers to trust it for the session); a local file is always confirmed and a program refused, its folder offered; an agent’s request is always confirmed, one at a time per agent, five more queued, then refused. Links (the app.links service) holds it, with the opener.
  • Openers (Opener) do the opening: EguiOpener (the default: web pages and mail through egui’s OpenUrl, eframe’s links feature on native, a new tab on the web build), RecordingOpener (tests: records each call, answers as scripted), NullOpener (a headless node: refuses with the reason, or forwards). egui_pop_platform::open::SystemOpener adds local files, folders and Reveal.
  • egui’s own OpenUrl (ui.hyperlink, a third-party widget, ctx.open_url) is taken out of each frame’s output and opened through the same step, so no link bypasses the policy.
  • The widget (link, Link): the theme’s link colour, the real target on hover (an internationalised host with its punycode), a context menu (Open, Open outside, Show in folder, Copy link), Enter and Space, Ctrl+click and middle click for outside, the role link with the target as its description.
  • Commands: links.open (target, how, dry_run: a dry run says the kind, how, whether it would ask and the verdict, opening nothing) and links.check for agents, files.reveal (path), and the links collector; lint checks the links an application declares.
use std::sync::Arc;
use egui_pop_api::links::{self, LinksPlugin, RecordingOpener, Request};
use egui_pop_api::App;

let rec = RecordingOpener::default();
let app = App::builder()
    .plugin(LinksPlugin::default().opener(Arc::new(rec.clone())))
    .build(&egui::Context::default())
    .unwrap();
let out = links::open(app.handle(), Request::new("https://example.org/"));
assert!(out.ok());
assert_eq!(rec.records()[0].target, "https://example.org/");

Modules§

lint
The links’ lint: every link the application declares checked against the application and the policy, so a renamed command, a removed file or a blocked scheme cannot leave a dead link behind.

Structs§

Caps
What the opener can do here.
Decision
What the policy decided.
EguiOpener
The default opener: web pages and mailto: through egui’s OpenUrl (eframe’s links feature, webbrowser, on native; a new tab on the web build, mailto: in the same tab, which hands it to the mail client). Local files, folders and Reveal need the platform’s SystemOpener.
Facts
What is known of a local target, read by the caller (the policy never touches the disk).
Inline
A short text in the inline subset (ADR 0017): emphasis, strong, code and links ([label](target), <https://…>, a bare address), each link drawn with Link; tips, toasts and settings descriptions use it, so their text needs no markdown renderer. A text without any of it is a plain label. See egui_pop_model::links::inline for what is read.
Interceptor
egui’s plugin taking OpenUrl out of each frame’s output (every window’s): the commands the service approved go on to eframe, the others are opened through the service on the next pass.
Link
The link widget: the theme’s link colour and a pointing hand, the real target on hover, a context menu (Open, Open outside when the default is inside, Show in folder for a local file, Copy link), Enter and Space to open, Ctrl+click and middle click to open outside, role link with the label as its name and the target as its description.
Links
The links service: the policy and the opener, shared by the application’s windows.
LinksPlugin
The links service as a plugin (in DefaultPlugins): the policy and the opener (EguiOpener unless given), the link.open step, the interceptor of egui’s OpenUrl, the confirmation, the commands (links.open, links.check, links.copy, files.reveal) and the links collector.
NullOpener
An opener for a node without a screen: every request is refused with the reason (its link.failed in the journal), or forwarded to an attached interface when the host offers one.
OpenCall
One call to an opener: what to open and how, from where, for whom.
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.
Record
One call a RecordingOpener received.
RecordingOpener
An opener for tests: records each call (target, how, kind, source, origin) and answers as scripted (success by default), with every capability. Clones share the record.
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).
Opening
What an opener answers.
Reason
Why a link is refused.
Source
Where a link comes from: what the policy trusts.

Constants§

AGENT_QUEUE
How many requests of one agent wait behind its confirmation.
CMD_CHECK
What a link is and how it would open (target, how, source), opening nothing.
CMD_CONFIRMED
The user’s answer to a confirmation (id, trust): kept from agents and the palette.
CMD_COPY
Copies a link (target), through the clipboard.
CMD_OPEN
Opens a link (target, how, label, dry_run); an agent’s request is always confirmed by the user.
CMD_REVEAL
Shows a file in its folder (path).
ENDPOINT
The clipboard endpoint a link is copied from.
LINKS
The links service: the policy and the opener.
PLUGIN
The plugin’s id.
RECENT
How many requests the links collector keeps.
STEP_OPEN
Opening a link ({ target, how, source, label, origin, dry_run }): a before-hook vetoes it or redirects it (another target, another way); a run-hook opens it its own way; its default decides through the policy, asks the user when it must, and has the opener open it. Its result: the decision and the status (opened, opening, asked, queued, or a dry run’s verdict).

Traits§

Inside
What shows pages and images inside the application (the viewer of egui_pop_views::viewer, or the host’s own): the links service hands it each request the policy sends inside (docs: pages, pages on the application’s documentation hosts, local images, local videos when it plays them, YouTube videos when it plays those), after the policy and the user’s confirmation.
Opener
What opens a link outside the application, replaceable by the host (ADR 0010): a kiosk opening nothing, a host opening in its own browser, a headless node forwarding to an attached interface.

Functions§

copy_link
Copies a link: through the clipboard (the clipboard.copy step, a text/uri-list item with its text) when its plugin is connected, else as text.
decide
What the policy decides for a request now, with the opener’s capabilities and what the disk says (nothing is opened).
declare
Declares a link the application shows (About, help, a tip): checked by lint (the plugin-owned form is Ctx::link).
declared
The links declared (place, target) and those drawn as declared so far (drawn, the label).
dry_run
What opening a link would do (the kind, how, whether it asks, the verdict) through the STEP_OPEN step, opening nothing.
emit_approved
Emits egui’s OpenUrl for a link the policy approved: the interceptor lets it through to eframe.
facts_of
What is known of a local target on disk (nothing on the web build).
inline
Draws a short text the application declares in the inline subset; see Inline.
link
Draws a link the application declares; see Link.
links
The links service, when the plugin is connected.
open
Opens a link through the STEP_OPEN step. A refusal or a failure asked by the user shows in a toast with Copy link (or Show in folder for a program); a request needing a confirmation opens it and ends asked (or queued behind an agent’s earlier one).
recent
The requests seen lately, oldest first, as the links collector shows them.