Skip to main content

Persisted

Trait Persisted 

Source
pub trait Persisted:
    Clone
    + Send
    + Sync
    + 'static {
    // Required methods
    fn load(key: &str, fallback: Self) -> Self;
    fn store(key: &str, value: &Self);
}
Expand description

A type UserDefaults can hold, and that a binding can therefore persist.

The four AppStorage supports without a RawRepresentable detour.

Required Methods§

Source

fn load(key: &str, fallback: Self) -> Self

The stored value, or fallback when nothing is stored.

Source

fn store(key: &str, value: &Self)

Write, replacing whatever was there.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl Persisted for String

Source§

fn load(key: &str, fallback: Self) -> Self

Source§

fn store(key: &str, value: &Self)

Source§

impl Persisted for bool

Source§

fn load(key: &str, fallback: Self) -> Self

Source§

fn store(key: &str, value: &Self)

Source§

impl Persisted for f64

Source§

fn load(key: &str, fallback: Self) -> Self

Source§

fn store(key: &str, value: &Self)

Source§

impl Persisted for i64

Source§

fn load(key: &str, fallback: Self) -> Self

Source§

fn store(key: &str, value: &Self)

Implementors§