pub struct HookMetadata {
pub entity_type: Option<&'static str>,
pub phase: HookPhase,
}Expand description
Metadata describing what dispatch context a hook name belongs to. See module docs.
Fields§
§entity_type: Option<&'static str>Entity type the hook applies to ("tool", "llm", "prompt",
"resource"). None means “applies regardless of entity_type”
— used for hooks that don’t tie to MCP’s entity-type taxonomy.
phase: HookPhaseLifecycle phase the hook occupies.
Implementations§
Source§impl HookMetadata
impl HookMetadata
Sourcepub const fn unknown() -> Self
pub const fn unknown() -> Self
Default — entity_type: None, phase: Unphased. Used as
the fallback for hook names not in the registry. The
matches function treats Unphased as “matches any phase,”
so unknown hooks dispatch on the first registered entry.
Sourcepub fn matches(
&self,
request_entity_type: Option<&str>,
requested_phase: HookPhase,
) -> bool
pub fn matches( &self, request_entity_type: Option<&str>, requested_phase: HookPhase, ) -> bool
Whether this hook’s metadata matches a dispatch context.
Matching rules:
entity_type: a hook tied to a specific entity_type (Some("tool")) matches only contexts with that entity type. A hook withentity_type: Nonematches any context. A request without an entity_type (None) matches any hook — the dispatcher hasn’t specified what entity is in play, so we can’t filter on it.phase: exact match between hook’s phase and the requested phase, EXCEPTUnphasedis a wildcard from either side (lets custom / unregistered hooks dispatch without phase rules).
Trait Implementations§
Source§impl Clone for HookMetadata
impl Clone for HookMetadata
Source§fn clone(&self) -> HookMetadata
fn clone(&self) -> HookMetadata
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for HookMetadata
Source§impl Debug for HookMetadata
impl Debug for HookMetadata
impl Eq for HookMetadata
Source§impl PartialEq for HookMetadata
impl PartialEq for HookMetadata
impl StructuralPartialEq for HookMetadata
Auto Trait Implementations§
impl Freeze for HookMetadata
impl RefUnwindSafe for HookMetadata
impl Send for HookMetadata
impl Sync for HookMetadata
impl Unpin for HookMetadata
impl UnsafeUnpin for HookMetadata
impl UnwindSafe for HookMetadata
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.