Skip to main content

AppData

Type Alias AppData 

Source
pub type AppData = ContainerSendSync;
Expand description

Alias for data Container

It will usually be wrapped in a std::sync::Arc. This Container does not provide interior mutability.

More about the container state::Container

§Example

let app_data = AppData::new();
app_data.set("Test".to_string());

let value = app_data.get::<String>();
assert_eq!(value, "Test");

let value = app_data.get_or_default::<usize>();
assert_eq!(value, &0);

Aliased Type§

pub struct AppData { /* private fields */ }

Trait Implementations§

Source§

impl AppDataExt for AppData

Source§

fn get_or_default<T: Default + Send + Sync + 'static>(&self) -> &T

Attempts to retrieve the global state for type T. If it hasn’t been initialize, a new one T will be created using Default::default