pub struct HatRegistry { /* private fields */ }Expand description
Registry for managing and creating hats from configuration.
Implementations§
Source§impl HatRegistry
impl HatRegistry
Sourcepub fn from_config(config: &RalphConfig) -> Self
pub fn from_config(config: &RalphConfig) -> Self
Creates a registry from configuration.
Empty config → empty registry (HatlessRalph is the fallback, not default hats).
Sourcepub fn register_with_config(&mut self, hat: Hat, config: HatConfig)
pub fn register_with_config(&mut self, hat: Hat, config: HatConfig)
Registers a hat with its configuration.
Sourcepub fn get_config(&self, id: &HatId) -> Option<&HatConfig>
pub fn get_config(&self, id: &HatId) -> Option<&HatConfig>
Gets a hat’s configuration by ID.
Sourcepub fn subscribers(&self, topic: &Topic) -> Vec<&Hat>
pub fn subscribers(&self, topic: &Topic) -> Vec<&Hat>
Finds all hats subscribed to a topic.
Sourcepub fn find_by_trigger(&self, topic: &str) -> Option<&HatId>
pub fn find_by_trigger(&self, topic: &str) -> Option<&HatId>
Finds the first hat that would be triggered by a topic. Returns the hat ID if found, used for event logging.
Sourcepub fn has_subscriber(&self, topic: &str) -> bool
pub fn has_subscriber(&self, topic: &str) -> bool
Returns true if any hat is subscribed to the given topic.
Sourcepub fn get_for_topic(&self, topic: &str) -> Option<&Hat>
pub fn get_for_topic(&self, topic: &str) -> Option<&Hat>
Returns the first hat subscribed to the given topic.
Uses prefix index for O(1) early-exit when the topic prefix doesn’t match any subscription pattern.
Trait Implementations§
Source§impl Debug for HatRegistry
impl Debug for HatRegistry
Source§impl Default for HatRegistry
impl Default for HatRegistry
Source§fn default() -> HatRegistry
fn default() -> HatRegistry
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for HatRegistry
impl RefUnwindSafe for HatRegistry
impl Send for HatRegistry
impl Sync for HatRegistry
impl Unpin for HatRegistry
impl UnwindSafe for HatRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Erasable for T
impl<T> Erasable for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more