dirmgr: add Store trait & MemoryStore impl
As discussed in #267 (closed), here goes the Store trait to abstract the caching done in tor-dirmgr. To actually try it out, I've also added a MemoryStore (behind a feature flag) that shows how to select between two Store implementation (and that can be used in wasm!).
-
Storetrait is mostly allpub fnfromSqliteStore, minus the constructors- also, removed the use of iterator as dynamic object can't be parametrized per function
-
MemoryStoreis selected for tests when the feature is activated - configuration is a bit more complex now, as one can select between two
Storeimpl. I'm sure that you've a nicer way to do it😅 - also, it kinda duplicates configuration as
arti_client::StorageCacheConfig::SqliteusesCfgPathbuttor_dirmgr::StorageConfig::SqliteusesPathBuf - and sadly
derive_builderdoesn't supports nested builder, so that less nice than wanted (config.cache(StorageCacheConfig::Sqlite{ directory: CfgPath::new("/tmp".to_owned()) })vsconf.storage().sqlite("/tmp")👀 )
- also, it kinda duplicates configuration as
[storage]
cache = { sqlite = { directory = "${ARTI_CACHE}" } }
# cache = "memory"
NB: this PR is actually not really useful for fixing #267 (closed), as having hooks or a custom DirProvider does the trick, but I coded it, hopefully it'll help you
Edited by tharvik