pub enum ConfigValue {
Null,
Bool(bool),
Number(f64),
String(String),
Array(Vec<ConfigValue>),
Object(Vec<(String, ConfigValue)>),
Regex {
pattern: String,
flags: String,
},
Unknown,
OneOf(Vec<ConfigValue>),
}Expand description
A statically known value from a config file.
Variants§
Null
null.
Bool(bool)
true or false.
Number(f64)
A numeric literal.
String(String)
A string literal, or a string computed from known values (a template literal, a concatenation, a path).
Array(Vec<ConfigValue>)
An array literal; spreads of static arrays are flattened, anything else becomes ConfigValue::Unknown.
Object(Vec<(String, ConfigValue)>)
An object literal in source order. A spread of an unknown value is recorded as the key UNKNOWN_SPREAD, or
OWN_SPREAD when the module computes the value itself.
Regex
A regular expression literal.
Fields
Unknown
Anything that cannot be known without running the code.
OneOf(Vec<ConfigValue>)
One of these values, without knowing which: the branches of a condition that cannot be decided statically
(process.env.CI ? 'github' : 'list'). There are at least two alternatives, all different, and none is
ConfigValue::Unknown or another OneOf, though an array or object alternative may hold unknown parts.
ConfigValue::is_unknown and ConfigValue::has_unknown count it as unknown, so code that does not ask
for its ConfigValue::alternatives treats it as an unknown value.
Implementations§
Source§impl ConfigValue
impl ConfigValue
Sourcepub fn is_spread_key(key: &str) -> bool
pub fn is_spread_key(key: &str) -> bool
Whether key is a key an object records an unknown spread under, UNKNOWN_SPREAD or OWN_SPREAD.
Sourcepub fn get(&self, key: &str) -> Option<&ConfigValue>
pub fn get(&self, key: &str) -> Option<&ConfigValue>
The value of key when this is an object.
Sourcepub fn as_array(&self) -> Option<&[ConfigValue]>
pub fn as_array(&self) -> Option<&[ConfigValue]>
The elements when this is an array.
Sourcepub fn as_object(&self) -> Option<&[(String, ConfigValue)]>
pub fn as_object(&self) -> Option<&[(String, ConfigValue)]>
The entries when this is an object.
Sourcepub fn is_unknown(&self) -> bool
pub fn is_unknown(&self) -> bool
Whether the value is not known as one value: ConfigValue::Unknown, or ConfigValue::OneOf of several.
Sourcepub fn alternatives(&self) -> &[ConfigValue]
pub fn alternatives(&self) -> &[ConfigValue]
The values this may be: the alternatives of a ConfigValue::OneOf, or the value itself.
Sourcepub fn has_unknown(&self) -> bool
pub fn has_unknown(&self) -> bool
Whether the value, or anything inside it, is ConfigValue::Unknown or ConfigValue::OneOf.
Trait Implementations§
Source§impl Clone for ConfigValue
impl Clone for ConfigValue
Source§impl Debug for ConfigValue
impl Debug for ConfigValue
Source§impl<'de> Deserialize<'de> for ConfigValue
impl<'de> Deserialize<'de> for ConfigValue
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>,
Source§impl PartialEq for ConfigValue
impl PartialEq for ConfigValue
Source§impl Serialize for ConfigValue
impl Serialize for ConfigValue
impl StructuralPartialEq for ConfigValue
Auto Trait Implementations§
impl Forget for ConfigValue
impl Freeze for ConfigValue
impl Move for ConfigValue
impl RefUnwindSafe for ConfigValue
impl Send for ConfigValue
impl Sync for ConfigValue
impl Unpin for ConfigValue
impl UnsafeUnpin for ConfigValue
impl UnwindSafe for ConfigValue
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more