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§
Provided Methods§
Sourcefn load<S: AsRef<str>>(filename: S) -> Self
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.
Sourcefn try_load<S: AsRef<str>>(filename: S) -> Result<Self, Error>
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.
Sourcefn fallback_load<S: AsRef<str>, P: AsRef<Path>>(
filename: S,
path: Option<P>,
) -> Self
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.