Skip to main content

Module capability_door

Module capability_door 

Expand description

The capability door: privilege is granted, never inferred.

A privileged verb declares the Capability it needs and, before the app draws a control for it, asks for the capability’s Resolution:

ResolutionWhat the surface draws
Resolution::Grantedthe real control, doing the real thing
Resolution::Grantablethe control plus an explicit grant step, in the person’s words
Resolution::Unavailableno control at all: one sentence of why, and what would make it available

A Door packages the capability with its resolution so a view cannot accidentally draw the granted face for a grantable or unavailable one: Door::face is the three-way choice, Door::control the common “only when granted” shorthand.

No inert control may exist: a control for a privileged act is drawn only in the granted face. Discovery is not resolution: which(), $PATH and environment variables are test seams (#[cfg(test)], the testing module), never the product path.

use tilo_ui::capability_door::{Capability, Door};

let door = Door::grantable(Capability::FIREWALL, "Tilo needs your permission to change firewall rules");
let shown: Option<&str> = door.control(|| "the Apply button");
assert!(shown.is_none(), "a grantable verb draws no inert control");
let grant = door.grant_words().expect("the grant step names itself");
assert!(grant.contains("permission"));

The verdict’s source is the host or the platform (Authority::resolve): an app its host gives a verdict holds a Door, a capture or test holds one built directly, so neither needs an environment variable to say what it can do.

Structs§

Capability
A privileged capability an app may be granted, named by the thing it reaches (network.firewall, storage.format, session.remote).
Door
A capability and its resolution: the one thing a view asks before drawing a privileged control.

Enums§

Resolution
What the platform says about a capability right now.

Traits§

Authority
The thing that answers Capability questions: the host, a portal, or a test fixture. The product path asks this; it never asks the environment.

Functions§

door
The door authority gives capability.