settings_storage::device_storage

Trait DeviceStorageCompatible

Source
pub trait DeviceStorageCompatible:
    Serialize
    + DeserializeOwned
    + Clone
    + PartialEq
    + Any {
    type Loader: DefaultDispatcher<Self>;

    const KEY: &'static str;

    // Provided methods
    fn try_deserialize_from(value: &str) -> Result<Self, Error> { ... }
    fn extract(value: &str) -> Result<Self, Error> { ... }
    fn serialize_to(&self) -> String { ... }
}
Expand description

Structs that can be stored in device storage

Structs that can be stored in device storage should derive the Serialize, Deserialize, and Clone traits, as well as provide constants. KEY should be unique the struct, usually the name of the struct itself. DEFAULT_VALUE will be the value returned when nothing has yet been stored.

Anything that implements this should not introduce breaking changes with the same key. Clients that want to make a breaking change should create a new structure with a new key and implement conversion/cleanup logic. Adding optional fields to a struct is not breaking, but removing fields, renaming fields, or adding non-optional fields are.

Required Associated Constants§

Source

const KEY: &'static str

Required Associated Types§

Provided Methods§

Source

fn try_deserialize_from(value: &str) -> Result<Self, Error>

Source

fn extract(value: &str) -> Result<Self, Error>

Source

fn serialize_to(&self) -> String

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§