boxdot / gurk-rs

Signal Messenger client for terminal
GNU Affero General Public License v3.0
458 stars 33 forks source link

Granular storage #185

Closed boxdot closed 1 year ago

boxdot commented 1 year ago

This commit introduces a new Storage trait, which allows granular storage and retrieval of channels, messages, names and metadata. Implementations of this trait can choose whether they return owned data (in case they don't store the data as is) or borrowed data (in case, the data is stored as is). The interfaces does not allow the modification of data in-place (which would be the most efficient approach), however it provides a greater flexibility, which is in particular needed for storages not storing the data as is.

The app_data field is removed and the access to channels and messages is done via ids into the storage. Channels are identified by ChannelId, messages by the channel they belong to and arrived_at. Channels do not contain messages anymore.

The storage trait is implemented for the current (non-efficient) json data model.

This is a pre-requisite to migrate to a sled backend.