Skip to main content

HasState

Trait HasState 

Source
pub trait HasState<T>: StateRegistry { }
Expand description

Marker trait indicating that type T is present in state registry S.

This trait is automatically implemented for any type T that appears in the nested tuple structure of S.

§Example

// (DbPool, (Config, ())) contains both DbPool and Config
fn requires_db<S: HasState<DbPool>>() {}
fn requires_config<S: HasState<Config>>() {}

// Both work with (DbPool, (Config, ()))
type MyState = (DbPool, (Config, ()));
requires_db::<MyState>();   // compiles
requires_config::<MyState>(); // compiles

Implementations on Foreign Types§

Source§

impl<T: Send + Sync + 'static, S: StateRegistry> HasState<T> for (T, S)

Implementors§