pub enum ConfigFormat {
JSON,
JSON5,
TOML,
YAML,
}Expand description
Enum used to configure the Configs file format.
You can use it in a ConfigSetupOptions, inside Config::from_options
§⚠️ Make sure to enable the feature flag for a format before using it!
Variants§
Implementations§
Source§impl ConfigFormat
impl ConfigFormat
Sourcepub fn from_extension(ext: &OsStr) -> Option<Self>
pub fn from_extension(ext: &OsStr) -> Option<Self>
Mainly used to convert file extensions into ConfigFormats
Also chooses the correct extension for both JSON types based on the enabled feature. (ex: if JSON5 is enabled, it chooses it for the “json” file extension)
Returns Option::None if the string/extension doesn’t match any known format.
§Example:
if cfg!(feature = "json") {
assert_eq!(
ConfigFormat::from_extension(OsStr::new("json")).unwrap(),
ConfigFormat::JSON
);
} else if cfg!(feature = "json5") {
assert_eq!(
ConfigFormat::from_extension(OsStr::new("json5")).unwrap(),
ConfigFormat::JSON5
);
}Trait Implementations§
Source§impl Clone for ConfigFormat
impl Clone for ConfigFormat
Source§fn clone(&self) -> ConfigFormat
fn clone(&self) -> ConfigFormat
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ConfigFormat
impl Debug for ConfigFormat
Source§impl Default for ConfigFormat
impl Default for ConfigFormat
Source§impl Display for ConfigFormat
impl Display for ConfigFormat
Source§impl PartialEq for ConfigFormat
impl PartialEq for ConfigFormat
impl Copy for ConfigFormat
impl StructuralPartialEq for ConfigFormat
Auto Trait Implementations§
impl Freeze for ConfigFormat
impl RefUnwindSafe for ConfigFormat
impl Send for ConfigFormat
impl Sync for ConfigFormat
impl Unpin for ConfigFormat
impl UnwindSafe for ConfigFormat
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more