Skip to main content

Module mount

Module mount 

Source
Expand description

The mount contract (ADR 0013): a component says what it needs (Mountable), a host says what it offers (HostOffer), and check matches the two with eleven named rules (Rule).

A pair either fits, fits under named conditions, or does not fit, with a reason of one kind: by design (a rule kept on purpose, with what to do instead), an egui-pop limit (work not done yet), or an upstream limit (egui, eframe or another dependency). Each condition and reason is a Code whose text lives once, in CODES: the generated docs/hosts.md, the reported refusals and the debug bridge all show that text.

use egui_pop_model::mount::{self, Fit, HostOffer, HostSize, Mountable};

let viewport = Mountable::new("viewport", "Image viewport").fills();
let status_bar = HostOffer::new("status-bar", "S", "Status bar").size(HostSize::Row);
match mount::check(&viewport, &status_bar) {
    Fit::No { refusal, .. } => assert_eq!(refusal.code, "D1"),
    other => panic!("{other:?}"),
}

Modules§

page
docs/hosts.md, written from the declarations: the hosts and their offers, the components and their needs, the matrix of check verdicts, the rules, the conditions and the reasons, and the counts. cargo xtask hosts writes it; a test fails when the committed page differs from a fresh one.

Structs§

Code
A condition or a reason, written once.
Condition
A condition a fit is under.
HostOffer
What a host offers what is mounted in it.
Mountable
What a component needs from the place it is mounted in.
Pointer
What a component does with the pointer.
Refusal
Why a pair does not fit.
SizeNeed
The size a component needs, in points.

Enums§

ClaimKey
A key a component may claim, and a host may own.
CodeKind
The kind of a Code.
Dismiss
What closes a transient host.
Display
The colours a component needs.
Fit
Whether a component fits a host.
FocusPolicy
Who gets the keyboard in a host.
HostDisplay
The colours a host can show.
HostSize
The room a host gives.
Instances
How many of a component an application may show.
Keep
What a host keeps across showings and restarts.
Keyboard
How a component uses the keyboard.
Lifetime
Rule
The matching rules, in the order they are checked.
Window
Which window a host is in.
Workers
Work done off the interface thread for a component.

Constants§

CODES
Every condition and reason.
ROW_HEIGHT
The height of a line host (a bar, the status bar), in points: a component needing more does not fit there.

Functions§

check
Matches a component’s needs against a host’s offer with the eleven rules: the worst verdict wins, every condition is kept, a refusal names its rule and code.
code
A condition or a reason by its code.