-
Notifications
You must be signed in to change notification settings - Fork 0
Write support #114
Description
For a "merged config object" like the old config-rs, I would assume that the first step of writing config would be to diff the merged object with another using default values. The layered approach of config-rs-ng provides a better option, namely that an appropriate layer can be selected when attempting to save a value. Potentially the appropriate layer could be chosen explicitly or could be chosen based on having write support.
Only one (or a small number) of types of layer need support writing. As mentioned in the blog, it would be nice if the writer is configuration-preserving, but this is not technically required.
I think a minimal-viable-candidate would be for layers to optionally support setting values (internally) and writing (write-to-source), along with a File layer which uses serialisation for writing.
A couple of complications:
- If a config-stack supports an optional user-configuration-file which is not present on the system, but this is the only source supporting writing, then presumably this layer needs to be created even though the file does not exist. This may also require the writer to create the target directory when writing.
- In the simplest case, all written values would go to the first layer in the stack supporting writing. This might not always be desired. I guess the easiest answer here is to allow optionally specifying which layer to use.