Module bdrck::configuration

source ·
Expand description

The configuration module contains utilities for persisting application configuration to disk.

Structs§

  • A Configuration represents a set of configuration values, initially loaded from disk, and which can be persisted back to disk e.g. just before the application exits. Generally it is expected that only one instance per Identifier is needed globally, and the other functions in this module are intended to provide an easy singleton interface for this class.
  • An Identifier uniquely identifies a configuration file.

Functions§

  • get returns the entire current set of configuration values in the configuration singleton matching the given identifier.
  • instance_apply is a very generic function which applies the given function to the configuration singleton matching the given identifier. It is an error if the identifier is unrecognized, or if the given callback operates on a Configuration of the wrong type.
  • instance_apply_mut is a very generic function which applies the given mutation function once to the configuration singleton matching the given identifier. It is an error if the identifier is unrecognized, or if the given callback operates on a Configuration of the wrong type.
  • new initializes a new configuration singleton with the given identifer, default set of configuration values, and custom disk persistence path (optional). An error might occur if determining the persistence path to use fails, or if deserializing the previously persisted configuration (if any) fails.
  • persist writes the configuration singleton matching the given identifier to disk.
  • remove persists and then removes the configuration singleton matching the given identifier. After calling this function, the configuration in question will be unavailable.
  • reset modifies the configuration singleton matching the given identifier to its default values.
  • set replaces all existing configuration values with the given entirely new set of configuration values in the configuration singleton matching the given identifier..