pub struct DashboardRegistry { /* private fields */ }Expand description
Ordered, id-keyed collection of sections.
Shadowing, not overwriting. A later registration for an id that is
already taken is appended, and the id resolves to the LAST entry.
That makes replace-by-id (CR.4’s stated capability — a plugin replacing
getting-started) a stack rather than a destructive write, so
unregister_plugin is a plain retain and
the displaced builtin resurfaces on its own. The alternative —
overwrite, and save the previous occupant somewhere for unload to put
back — is explicit bookkeeping across three unload paths, and the kind
that gets forgotten on one of them.
Implementations§
Source§impl DashboardRegistry
impl DashboardRegistry
pub fn new() -> Self
Sourcepub fn into_handle(self) -> DashboardRegistryHandle
pub fn into_handle(self) -> DashboardRegistryHandle
Wrap this registry in a fresh DashboardRegistryHandle, so
consumers do not each have to name arc_swap.
Sourcepub fn register(&mut self, section: Arc<dyn DashboardSection>) -> &mut Self
pub fn register(&mut self, section: Arc<dyn DashboardSection>) -> &mut Self
Register a section.
A registration for an id already held by a different owner
shadows it (see the type docs). A registration by the same owner
for the same id replaces in place, so re-running builtin_registry
stays idempotent and a plugin reload cannot grow the shadow stack.
Sourcepub fn unregister_plugin(&mut self, plugin_id: u64) -> usize
pub fn unregister_plugin(&mut self, plugin_id: u64) -> usize
Drop every section contributed by plugin_id, returning how many
were removed. Idempotent: a second call reports zero.
A builtin the plugin had shadowed becomes visible again with no
restore step, because it was never removed — that is the whole
reason register appends.
Sourcepub fn resolve(&self, id: &str) -> Option<&Arc<dyn DashboardSection>>
pub fn resolve(&self, id: &str) -> Option<&Arc<dyn DashboardSection>>
The section that currently owns id — the last registration for it.
Sourcepub fn ids(&self) -> Vec<&str>
pub fn ids(&self) -> Vec<&str>
All registered ids, de-duplicated, in FIRST-registration order (not the display order).
First-registration order rather than last: a plugin replacing a builtin keeps the slot the builtin occupied, so loading a plugin does not reshuffle the list a user reads.
Sourcepub fn ordered(
&self,
selection: &SectionSelection,
) -> Vec<Arc<dyn DashboardSection>>
pub fn ordered( &self, selection: &SectionSelection, ) -> Vec<Arc<dyn DashboardSection>>
Resolve the display order for a selection.
Unknown ids in an explicit selection are skipped with a logged
warning (never a hard error — a stale dashboard.sections entry must
not break the page).
Sourcepub fn compose(
&self,
ctx: &DashboardCtx,
selection: &SectionSelection,
) -> Vec<DashboardFragment>
pub fn compose( &self, ctx: &DashboardCtx, selection: &SectionSelection, ) -> Vec<DashboardFragment>
Render the selected sections in order to their fragments.
Trait Implementations§
Source§impl Clone for DashboardRegistry
impl Clone for DashboardRegistry
Source§fn clone(&self) -> DashboardRegistry
fn clone(&self) -> DashboardRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more