pub struct Settings {
pub prefer: ConfigFormat,
pub allow_json: bool,
pub allow_json5: bool,
pub allow_toml: bool,
}
Expand description
Which formats are allowed and which to prefer
Fields§
§prefer: ConfigFormat
The preferred configuration format. This is always allowed implicitly.
allow_json: bool
Explicit permission to parse as JSON
allow_json5: bool
Explicit permission to parse as JSON5.
Implicitly allows JSON as it is a subset of JSON5.
allow_toml: bool
Explicit permission to parse as TOML
Implementations§
Source§impl Settings
impl Settings
Sourcepub const fn allow_all(prefer: ConfigFormat) -> Self
pub const fn allow_all(prefer: ConfigFormat) -> Self
Creates a new settings instance that allows all formats but prefers the given one.
Sourcepub const fn prefer_json() -> Self
pub const fn prefer_json() -> Self
Allow all formats, but prefer JSON.
Sourcepub const fn prefer_json5() -> Self
pub const fn prefer_json5() -> Self
Allow all formats, but prefer JSON5.
Sourcepub const fn prefer_toml() -> Self
pub const fn prefer_toml() -> Self
Allow all formats, but prefer TOML.
Sourcepub const fn allow_only(prefer: ConfigFormat) -> Self
pub const fn allow_only(prefer: ConfigFormat) -> Self
Creates a new settings instance that only allows the given preferred format.
Sourcepub const fn only_json5() -> Self
pub const fn only_json5() -> Self
Only allows parsing as JSON5 (and JSON).
Sourcepub fn is_allowed(&self, test_for: ConfigFormat) -> bool
pub fn is_allowed(&self, test_for: ConfigFormat) -> bool
Wheter the settings allow the parsing the given configuration format.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Settings
impl<'de> Deserialize<'de> for Settings
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Copy for Settings
Auto Trait Implementations§
impl Freeze for Settings
impl RefUnwindSafe for Settings
impl Send for Settings
impl Sync for Settings
impl Unpin for Settings
impl UnwindSafe for Settings
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