Skip to main content

HookContextInner

Struct HookContextInner 

Source
pub struct HookContextInner {
    pub hooks: Vec<Box<dyn Any>>,
    pub arm_changed: usize,
    pub hook_index: usize,
    pub cleanups: Vec<Box<dyn FnOnce()>>,
}
Expand description

Internal storage for hook state, holding boxed Any values.

This struct is not exposed directly; use HookContext instead. The arm_changed flag tracks whether a match arm switch occurred; when toggled, the hook array is cleared to prevent signal leakage between different match arms.

Fields§

§hooks: Vec<Box<dyn Any>>

Storage for hook state values (signals, etc.).

§arm_changed: usize

The match arm index from the last render.

§hook_index: usize

Current hook index, incremented on each hook call and reset per render.

§cleanups: Vec<Box<dyn FnOnce()>>

Cleanup closures registered by hooks (e.g., use_signal) that must be executed when the hook context is cleared due to a match arm switch.

Implementations§

Source§

impl HookContextInner

Source

pub fn get_hooks(&self) -> &Vec<Box<dyn Any>>

Source

pub fn get_mut_hooks(&mut self) -> &mut Vec<Box<dyn Any>>

Source

pub fn set_hooks(&mut self, val: Vec<Box<dyn Any>>) -> &mut Self

Source

pub fn get_arm_changed(&self) -> usize

Source

pub fn get_mut_arm_changed(&mut self) -> &mut usize

Source

pub fn set_arm_changed(&mut self, val: usize) -> &mut Self

Source

pub fn get_hook_index(&self) -> usize

Source

pub fn get_mut_hook_index(&mut self) -> &mut usize

Source

pub fn set_hook_index(&mut self, val: usize) -> &mut Self

Source

pub fn get_cleanups(&self) -> &Vec<Box<dyn FnOnce()>>

Source

pub fn get_mut_cleanups(&mut self) -> &mut Vec<Box<dyn FnOnce()>>

Source

pub fn set_cleanups(&mut self, val: Vec<Box<dyn FnOnce()>>) -> &mut Self

Source§

impl HookContextInner

Source

pub fn new( hooks: Vec<Box<dyn Any>>, arm_changed: usize, hook_index: usize, cleanups: Vec<Box<dyn FnOnce()>>, ) -> Self

Trait Implementations§

Source§

impl Debug for HookContextInner

Source§

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

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

impl Default for HookContextInner

Source§

fn default() -> HookContextInner

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, 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 = !

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<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more