Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow freezing or locking of configuration from future alteration #2

Closed
mehcode opened this issue Jan 25, 2017 · 4 comments
Closed

Comments

@mehcode
Copy link
Owner

mehcode commented Jan 25, 2017

A Config instance should allow locking to prevent all future mutation. Sources would need to support some kind of roll-up.

config::freeze();
config::set("key", "value"); // does nothing and returns an error
@nugend
Copy link

nugend commented Feb 10, 2017

Is it possible to make a compile time option to panic or return a Result?

@tmccombs
Copy link
Contributor

What if a Config instance had a method like fn freeze(self) -> ConfigView that returned a ConfigView that only had read methods on it. Since it takes ownership of the config, the type and borrow checkers can enforce that the config is actually frozen.

That wouldn't work for the global config though. But maybe the global config should be removed (as mentioned in #17).

@mehcode
Copy link
Owner Author

mehcode commented Feb 12, 2017

Another thought to consider is how necessary this is.

#[derive(Deserialize)]
struct AppConfig { ... }

fn main() {
  // Setup config via config::merge [...]
  let c: AppConfig = config::get("$");
}

If something similar to the above is supported, perhaps we don't need a way to freeze the underlying config store.

@SergioBenitez I added this issue because you expressed a strong desire to have a frozen configuration. What do you think?

@mehcode mehcode modified the milestone: 0.5.0 Mar 3, 2017
@mehcode mehcode removed this from the 0.5.0 milestone Jun 14, 2017
@mehcode
Copy link
Owner Author

mehcode commented Jun 22, 2017

Closing this because deserialization is essentially freeze

@mehcode mehcode closed this as completed Jun 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants