Create new generic config abstraction #25
Reference in New Issue
Block a user
Delete Branch "new-config"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This change migrates the config logic to a new generic key+value abstraction. This allows config parameters to be get and set with arbitrary string keys. Config value types can be anything that serde knows how to serialize / deserialize.
Implementations:
Desktop:
Uses a json file in a platform specific directory (pulled from etcetera). This is mostly the same as the existing code. Implemented in
native_config.rsAndroid:
Uses the same mechanism as desktop, with a different path selection that calls out to the android apis (via jni) to get the correct directory.
Web:
Uses browser local storage. Values are stored as strings instead of actual json objects to keep things simple for now. We might want to update this at some point.
Desktop support:

Web support:


Android support:
@@ -50,11 +50,24 @@ pub trait AudioPlayerInterface {fn play_opus(&mut self, payload: &[u8]);}pub trait ConfigSystemInterface: Sized {I'll definitely rebase on top of this when you merge!
@@ -165,2 +174,4 @@let _ = assert_platform::<stub::StubPlatform>;};fn global_default_config() -> HashMap<String, serde_json::Value> {What is the default_config logic used for? It seems a bit tangled right now, and we might as well leave it out until we need it for some reason
The idea is that we might want default values for some config options. For example, we might want to default the voice activation detection mode to "raw amplitude" instead of "signal to noise". The platform vs global logic is to allow us to set a default value for all platforms and override it with a platform specific variable. I can remove this but I anticipate wanting a feature like this right away once we start adding different configuration toggles.
I guess the reason it feels weird to me is that instead of doing
config_get("thing").unwrap_or("default")you just have toconfig_get("thing").unwrap()and trust the default is somewhere else. But IDK, it is probably fine8c8f0c6ef2to55c8722b1e55c8722b1etoce4f3ee934