Skip to main content

PersistedValueKey

Trait PersistedValueKey 

Source
pub trait PersistedValueKey:
    Internal
    + Send
    + Sync
    + 'static {
    type Value: Persist;

    const NAME: &'static str;
}
Expand description

Type-safe key for persisted values storage.

Associates a string key name with a value type at compile time, preventing type mismatches while maintaining ergonomic usage.

Use the register_persisted_value! macro to create keys.

§Example

use bitwarden_state::register_persisted_value;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize)]
struct AppConfig {
    theme: String,
    auto_save: bool,
}

register_persisted_value!(CONFIG: AppConfig = "app_config");

Required Associated Constants§

Source

const NAME: &'static str

The key name the value is stored under.

Required Associated Types§

Source

type Value: Persist

The type stored under this key.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§