matrix-rust-sdk icon indicating copy to clipboard operation
matrix-rust-sdk copied to clipboard

State store custom usage pattern enhancements

Open gnunicorn opened this issue 2 years ago • 0 comments

Our StateStore implementation have a very rough and rudimentary custom API to allow developers using the API to save data with it. However that is very low level and pretty limited for broader patterns - you can only get and set custom key-value pairs:

https://github.com/matrix-org/matrix-rust-sdk/blob/fb1a2f6d9491367a53cef7a76a1ecd8b525888db/crates/matrix-sdk-base/src/store/mod.rs#L309-L323

While a common pattern that we've worked out with our stores is to provide lists of keys- and values that are prefixed in a certain way. With these implementations using (if activated) encryption internally, this isn't really possible, nor is it possible to iterate over an unknown list of prefixed keys, limiting the usefulness of the store.

Aside from providing some handy methods allowing you to use Serialize + Deserialize for keys + values and have the store figure out the details, I propose we also add [get|set]_prefixed_custom_value functions that allow to specify an array of prefixes in front of the key to allow the prefix-pattern (with encrypted data) we've been grown accustomed to also to be used by developers building on top of our SDK.

gnunicorn avatar Jun 03 '22 07:06 gnunicorn