pub trait ConfigManager {
    // Required methods
    fn config_file_path(&self) -> String;
    fn encode_pretty(&self, pretty_format: bool) -> String;
    fn decode(&self, json_string: &str);

    // Provided methods
    fn load(&self) -> bool { ... }
    fn load_bak(&self) -> bool { ... }
    fn persist_with_topic<T>(&mut self, _topic_name: &str, _t: T) { ... }
    fn persist_map<T>(&mut self, _m: &HashMap<String, T>) { ... }
    fn persist(&self) { ... }
    fn decode0(&mut self, _key: &[u8], _body: &[u8]) { ... }
    fn stop(&mut self) -> bool { ... }
    fn encode(&mut self) -> String { ... }
}

Required Methods§

source

fn config_file_path(&self) -> String

Returns the path of the configuration file.

This method is a placeholder for returning the path of the configuration file. The actual implementation should be provided by the implementer of the trait.

source

fn encode_pretty(&self, pretty_format: bool) -> String

Encodes the configuration with pretty format.

This method is a placeholder for encoding the configuration with pretty format. The actual implementation should be provided by the implementer of the trait.

source

fn decode(&self, json_string: &str)

Decodes the configuration from a JSON string.

This method is a placeholder for decoding the configuration from a JSON string. The actual implementation should be provided by the implementer of the trait.

Provided Methods§

source

fn load(&self) -> bool

Loads the configuration from a file.

This method attempts to load the configuration from a file whose path is returned by config_file_path. If the file content is empty, it attempts to load from a backup file. If the file content is not empty, it decodes the content and logs a success message.

§Returns
  • true if the configuration is successfully loaded and decoded.
  • false if the configuration loading fails.
source

fn load_bak(&self) -> bool

Loads the configuration from a backup file.

This method attempts to load the configuration from a backup file whose path is returned by config_file_path with “.bak” appended. If the file content is not empty, it decodes the content and logs a success message.

§Returns
  • true if the configuration is successfully loaded and decoded.
  • false if the configuration loading fails.
source

fn persist_with_topic<T>(&mut self, _topic_name: &str, _t: T)

Persists the configuration with a topic.

This method persists the configuration with a given topic. The actual implementation is delegated to the persist method.

source

fn persist_map<T>(&mut self, _m: &HashMap<String, T>)

Persists the configuration with a map.

This method persists the configuration with a given map. The actual implementation is delegated to the persist method.

source

fn persist(&self)

Persists the configuration.

This method persists the configuration to a file whose path is returned by config_file_path. If the encoded configuration is not empty, it writes the configuration to the file.

source

fn decode0(&mut self, _key: &[u8], _body: &[u8])

Decodes the configuration.

This method is a placeholder for decoding the configuration. The actual implementation should be provided by the implementer of the trait.

source

fn stop(&mut self) -> bool

Stops the configuration manager.

This method is a placeholder for stopping the configuration manager. The actual implementation should be provided by the implementer of the trait.

§Returns
  • true by default.
source

fn encode(&mut self) -> String

Encodes the configuration.

This method is a placeholder for encoding the configuration. The actual implementation should be provided by the implementer of the trait.

Object Safety§

This trait is not object safe.

Implementors§