Skip to main content

Module ids

Module ids 

Source
Expand description

Typed ids (ADR 0002): one newtype per namespace, sharing one syntax, serialized as plain strings.

use egui_pop_model::ids::{CommandId, ZoneId};

const SIDEBAR: ZoneId = ZoneId::from_static("app.sidebar");
let palette = CommandId::new("view.palette").unwrap();
assert_eq!(palette.as_str(), "view.palette");
assert_eq!(serde_json::to_string(&SIDEBAR).unwrap(), "\"app.sidebar\"");
assert!(CommandId::new("has space").is_err());

An invalid literal in from_static is a compile error when used in a constant:

ⓘ
use egui_pop_model::ids::ZoneId;
const BAD: ZoneId = ZoneId::from_static("no spaces allowed");

Structs§

BlockId
A block in a zone.
CommandId
A command: view.palette, file.save.
FrameId
A frame of the context stack (ADR 0012): a place (demo.album) or a mode (demo.orientation.culling).
GroupId
A group of modes, one active at a time (orientation): the context key mode.<group>, so letters, digits, _ and ..
HookId
A hook point declarations are altered at.
IdError
Why a text is not an id.
MenuId
A menu: app.main, panel.tab.
OwnerId
Who registered something: a plugin’s id, framework, user.
PanelId
A panel: app.log; an instance of a panel declared with several (PanelSpec::instances) adds #<n>: app.gallery#2.
PluginId
A plugin: gallery.overview.
ScopeId
A history (ADR 0014): one undo line, a document’s edit, a collection’s marks, the settings window (app, settings).
ServiceId
A service plugins share.
SettingId
A setting, also its path in the value store under settings/.
StepId
A step of a feature’s life that plugins may watch, veto, replace or extend: frame.close, workbench.detach.
StoryId
A gallery story.
ZoneId
A zone where blocks are drawn: app.sidebar.

Constants§

MAX_ID_LEN
The longest id, in bytes.
SETTINGS_PREFIX
Where settings live in the value store: a setting id is at settings/<id> (SettingId::path).

Functions§

check
Checks the shared syntax: ASCII letters, digits and . _ - / :, not empty, at most MAX_ID_LEN bytes. Err holds the reason.
check_panel
Checks a panel id: the shared syntax (check), and an instance’s #<n> after it (app.gallery#2, ADR 0002’s panel instances), n a number from 2 without leading zeros (the panel declared is instance 1).