Skip to main content

register_persisted_value

Macro register_persisted_value 

Source
macro_rules! register_persisted_value {
    ($(#[$meta:meta])* $vis:vis $name:ident: $ty:ty = $key:literal) => { ... };
}
Expand description

Register a type-safe persisted value key.

This macro is the primary way to create persisted value keys. It associates a string key name with a value type at compile time.

Important: The key name must be globally unique across the entire application. Using the same key name for different persisted values will cause conflicts. It may contain only ASCII letters and underscores, which is checked at compile time.

ยง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");