pub trait Store: Clone + 'static {
// Required method
fn create() -> Self;
// Provided method
fn spawn(&self, future: impl Future<Output = ()> + 'static) -> TaskHandle { ... }
}Expand description
App-wide state, created once per app by use_store.
Required Methods§
Provided Methods§
Sourcefn spawn(&self, future: impl Future<Output = ()> + 'static) -> TaskHandle
fn spawn(&self, future: impl Future<Output = ()> + 'static) -> TaskHandle
Runs future on the UI thread in the store’s scope, for its
actions’ async work: it goes on when the view that called the
action goes away, and stops with the store. The store is the one
use_store finds from the caller’s scope, provided or the app’s.
ⓘ
fn rename(&self, path: PathBuf, name: String) {
let store = *self;
self.spawn(async move {
let result = spawn_blocking(move || fs::rename(&path, &name)).await;
store.renamed(result);
});
}§Panics
Outside of an app, or for a store neither provided above this
scope nor made by use_store.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".