pub trait Store: Send + Sync {
// Required methods
fn get(&self, key: &str) -> Option<String>;
fn set(&self, key: &str, value: &str) -> Result<(), String>;
fn clear(&self, key: &str);
fn keys(&self) -> Vec<String>;
}Expand description
Somewhere to remember things that are not secrets (ADR-0027).
The third place an addon can put something, after the settings file it is
given and the credential store it reaches through Credentials. Those two
are split by what the thing is: settings are written by the user and are
explicitly shareable, credentials are the whole of an account’s authority.
This is for everything that is neither — a list of recently used things, a
cache, an ordering somebody arranged — which previously had nowhere to go.
§Three things worth knowing before using it
It is encrypted at rest and you cannot switch that off. The host holds the key material and does the work; what crosses this interface is plaintext. An addon does not decide, because an addon that forgot would produce a plaintext file indistinguishable from one that had thought about it.
That is protection at rest and nothing more. The host must be able to decrypt in order to hand the value back, so anything running as the same user can obtain the same plaintext. It defends a profile directory that is copied, synced, backed up or attached to a bug report. Do not tell a user it does more.
It can forget. A store whose key material is gone reads as empty rather
than as an error — see Self::get. Anything that cannot survive being
forgotten belongs in the settings file or the credential store instead.
Required Methods§
Sourcefn get(&self, key: &str) -> Option<String>
fn get(&self, key: &str) -> Option<String>
Read one, or None.
None covers never written, cleared, and the key material is no
longer readable. Deliberately one answer: the last is indistinguishable
from the first without leaking whether a value once existed, and an
addon could not act differently on it anyway.
Sourcefn set(&self, key: &str, value: &str) -> Result<(), String>
fn set(&self, key: &str, value: &str) -> Result<(), String>
Write one.
§Errors
If the host refused — no implementation on this platform, or the write failed. Storing less than you wanted is recoverable; storing it in the clear instead is not, so there is no fallback.