Skip to main content

NavStore

Trait NavStore 

Source
pub trait NavStore {
    // Required methods
    fn load(&self, key: &str) -> Option<String>;
    fn save(&self, key: &str, value: &str);
}
Expand description

A key/value sink a nav surface’s .restore persists its state through, so navigation survives a relaunch or an Android process death (docs/navigation.md). day::launch installs the preferences store (day_part_preferences::install_nav_store) unless the app installed one first; an app marks the surfaces it wants remembered with .restore(key). With no store installed, .restore is a silent no-op, so a surface’s .restore call never fails to build.

Keys are opaque to day-core and namespaced by the surface’s .restore(key) argument; the store implementation is responsible for keeping them clear of the app’s own data.

Required Methods§

Source

fn load(&self, key: &str) -> Option<String>

The last value saved under key, or None if nothing was stored (first launch).

Source

fn save(&self, key: &str, value: &str)

Persist value under key, replacing any prior value.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§