Skip to main content

HelpRegistry

Struct HelpRegistry 

Source
pub struct HelpRegistry { /* private fields */ }
Expand description

Central registry mapping widget IDs to help content.

Supports:

Implementations§

Source§

impl HelpRegistry

Source

pub fn new() -> Self

Create an empty registry.

Source

pub fn register(&mut self, id: HelpId, content: HelpContent)

Register help content for a widget.

Overwrites any previous content (or lazy provider) for the same ID.

Source

pub fn register_lazy( &mut self, id: HelpId, provider: impl FnOnce() -> HelpContent + Send + 'static, )

Register a lazy provider that will be called on first lookup.

The provider is invoked at most once; its result is cached.

Source

pub fn unregister(&mut self, id: HelpId) -> bool

Remove help content for a widget.

Returns true if content was present.

Source

pub fn set_parent(&mut self, child: HelpId, parent: HelpId) -> bool

Set the parent of a widget in the help hierarchy.

When resolve is called for child and no content is found, the lookup walks to parent (and its ancestors).

Returns false (and does nothing) if setting this parent would create a cycle.

Source

pub fn clear_parent(&mut self, child: HelpId)

Remove the parent link for a widget.

Source

pub fn get(&mut self, id: HelpId) -> Option<&HelpContent>

Get help content for a specific widget (no hierarchy walk).

Forces lazy providers if present.

Source

pub fn peek(&self, id: HelpId) -> Option<&HelpContent>

Peek at help content without forcing lazy providers.

Source

pub fn resolve(&mut self, id: HelpId) -> Option<&HelpContent>

Resolve help content by walking the parent hierarchy.

Returns the first content found starting from id and walking up through parents. Returns None if no content exists in the chain.

Source

pub fn contains(&self, id: HelpId) -> bool

Check whether any help content is registered for this ID (including lazy).

Source

pub fn len(&self) -> usize

Number of registered entries (loaded + lazy).

Source

pub fn is_empty(&self) -> bool

Whether the registry is empty.

Source

pub fn ids(&self) -> impl Iterator<Item = HelpId> + '_

Iterate over all registered IDs.

Trait Implementations§

Source§

impl Debug for HelpRegistry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for HelpRegistry

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more