ConfigFile

Trait ConfigFile 

pub trait ConfigFile:
    DeserializeOwned
    + Sized
    + Send
    + 'static {
    // Required methods
    fn kind() -> &'static str;
    fn id(&self) -> &str;
    fn set_id(&mut self, id: String);

    // Provided methods
    fn load_blocking(path: &Path) -> Result<Self> { ... }
    fn post_load_blocking(&mut self) -> Result<()> { ... }
}
Expand description

A configuration file.

Required Methods§

fn kind() -> &'static str

Returns the kind of the configuration file.

This is used for logging purposes.

fn id(&self) -> &str

Returns the identifier of the configuration file.

fn set_id(&mut self, id: String)

Sets the identifier of the configuration file.

Provided Methods§

fn load_blocking(path: &Path) -> Result<Self>

Loads the configuration file from a path.

This function is blocking and should be called from a blocking context.

Calls post_load_blocking after loading the file.

§Default implementation

The default implementation treats the file as a TOML file and uses serde to deserialize it. If the resulting config returns an empty identifier, the file stem is used using set_id.

fn post_load_blocking(&mut self) -> Result<()>

Post-load blocking hook.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§