pub struct HookContext { /* private fields */ }Expand description
Manages hook state across render cycles for a DynamicNode.
Stores boxed Any values keyed by hook call order, enabling use_signal
and similar hooks to persist state between re-renders of the same
dynamic node.
Implements Copy for ergonomic use; all copies share the same underlying state.
SAFETY: The inner pointer is allocated via Box::leak and lives for the
entire program. This is safe in single-threaded WASM contexts where no
concurrent access can occur.
Implementations§
Source§impl HookContext
Implementation of hook context lifecycle and hook index management.
impl HookContext
Implementation of hook context lifecycle and hook index management.
Sourcepub fn from_inner(inner: *mut HookContextInner) -> Self
pub fn from_inner(inner: *mut HookContextInner) -> Self
Creates a new HookContext from an existing raw pointer.
§Safety
The caller must ensure the pointer was allocated via Box::leak
and remains valid for the entire program lifetime.
Sourcepub fn get_hook_index(&self) -> usize
pub fn get_hook_index(&self) -> usize
Returns the current hook index.
Sourcepub fn set_hook_index(&mut self, index: usize)
pub fn set_hook_index(&mut self, index: usize)
Sets the hook index.
Sourcepub fn get_mut_hooks(&mut self) -> &mut Vec<Box<dyn Any>>
pub fn get_mut_hooks(&mut self) -> &mut Vec<Box<dyn Any>>
Returns a mutable reference to the hooks storage.
Sourcepub fn reset_hook_index(&mut self)
pub fn reset_hook_index(&mut self)
Resets the hook index for a new render cycle.
Trait Implementations§
Source§impl Clone for HookContext
Clones the hook context, sharing the same inner state.
impl Clone for HookContext
Clones the hook context, sharing the same inner state.
Source§impl Default for HookContext
Provides a default empty hook context.
impl Default for HookContext
Provides a default empty hook context.
impl Copy for HookContext
Copies the hook context, sharing the same inner state.
A HookContext is just a raw pointer; copying it is a trivial bitwise copy.