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, fromegui_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.openruns them through thelink.openstep: a before-hook vetoes or redirects, a run-hook opens its own way, the journal sayslink.opened,link.failed,link.askedorlink.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(theapp.linksservice) holds it, with the opener. - Openers (
Opener) do the opening:EguiOpener(the default: web pages and mail through egui’sOpenUrl, eframe’slinksfeature 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::SystemOpeneradds 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 rolelinkwith 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) andlinks.checkfor agents,files.reveal(path), and thelinkscollector;lintchecks 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.
- Egui
Opener - The default opener: web pages and
mailto:through egui’sOpenUrl(eframe’slinksfeature, 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’sSystemOpener. - 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 withLink; tips, toasts and settings descriptions use it, so their text needs no markdown renderer. A text without any of it is a plain label. Seeegui_pop_model::links::inlinefor what is read. - Interceptor
- egui’s plugin taking
OpenUrlout 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
linkwith 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.
- Links
Plugin - The links service as a plugin (in
DefaultPlugins): the policy and the opener (EguiOpenerunless given), thelink.openstep, the interceptor of egui’sOpenUrl, the confirmation, the commands (links.open,links.check,links.copy,files.reveal) and thelinkscollector. - Null
Opener - An opener for a node without a screen: every request is refused with
the reason (its
link.failedin the journal), or forwarded to an attached interface when the host offers one. - Open
Call - 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
RecordingOpenerreceived. - Recording
Opener - 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
linkscollector 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 itplaysthem, YouTube videos when itplaysthose), 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.copystep, atext/uri-listitem 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 isCtx::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_OPENstep, opening nothing. - emit_
approved - Emits egui’s
OpenUrlfor 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_OPENstep. 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 endsasked(orqueuedbehind an agent’s earlier one). - recent
- The requests seen lately, oldest first, as the
linkscollector shows them.