Trait Load

Source
pub trait Load: Sized {
    // Required method
    fn try_fallback_load<S: AsRef<str>, P: AsRef<Path>>(
        filename: S,
        path: Option<P>,
    ) -> Result<Self, Error>;

    // Provided methods
    fn load<S: AsRef<str>>(filename: S) -> Self { ... }
    fn try_load<S: AsRef<str>>(filename: S) -> Result<Self, Error> { ... }
    fn fallback_load<S: AsRef<str>, P: AsRef<Path>>(
        filename: S,
        path: Option<P>,
    ) -> Self { ... }
}
Expand description

Load a struct from a configuration file.

Required Methods§

Source

fn try_fallback_load<S: AsRef<str>, P: AsRef<Path>>( filename: S, path: Option<P>, ) -> Result<Self, Error>

Loads the configuration from the given path or falls back to search if the path is None. Errors if file can’t be read or deserialized.

Provided Methods§

Source

fn load<S: AsRef<str>>(filename: S) -> Self

Find a configuration file and load the contents, falling back to the default.

§Panics

This will panic if there are any issues reading or deserializing the file. To catch these errors, use try_load instead.

Source

fn try_load<S: AsRef<str>>(filename: S) -> Result<Self, Error>

Find a configuration file and load the contents, falling back to the default. Errors if file can’t be read or deserialized.

Source

fn fallback_load<S: AsRef<str>, P: AsRef<Path>>( filename: S, path: Option<P>, ) -> Self

Loads the configuration from the given path or falls back to search if the path is None.

§Panics

This will panic if there are any issues reading or deserializing the file. To catch these errors, use try_load instead.

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§

Source§

impl<C> Load for C