Skip to main content

decode_persist_value

Function decode_persist_value 

Source
pub fn decode_persist_value<T>(
    key: &str,
    stored_value: &StoredValue,
    deserialize_fallback: Option<DeserializeFallback<T>>,
) -> Result<T, SettingsError>
Expand description

Decodes a persisted value, with an optional legacy fallback parser.

Normal JSON decoding is always attempted first. If it fails and deserialize_fallback is present, the fallback receives the raw stored string and may return a value of the requested type.

ยงErrors

Returns SettingsError::PersistValueParse when normal decoding fails and no fallback is present. Returns SettingsError::PersistFallbackParse when the fallback is present but cannot parse the raw value.