#[non_exhaustive]pub enum Value {
Boolean(bool),
Integer(i64),
String(String),
StringList(Vec<String>),
}Expand description
A configuration value, independent of any TOML or JSON library.
Every schema field holds exactly one of these shapes. Secret references
are carried as Value::String; whether a string is a secret reference is
a property of the field, not of the value.
With serde, a value serialises as the bare JSON scalar or array
("text", 42, true, ["a", "b"]) and deserialises from the same.
§Examples
use stratum_node_config::Value;
let v = Value::from(262_144);
assert_eq!(v.as_integer(), Some(262_144));
assert_eq!(v.to_string(), "262144");
assert_eq!(Value::from("a\"b").to_string(), r#""a\"b""#);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Boolean(bool)
A boolean.
Integer(i64)
A signed 64-bit integer, the range of a TOML integer.
String(String)
A UTF-8 string.
StringList(Vec<String>)
An ordered list of strings.
Implementations§
Source§impl Value
impl Value
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Returns the string if this is a Value::String.
Sourcepub fn as_integer(&self) -> Option<i64>
pub fn as_integer(&self) -> Option<i64>
Returns the integer if this is a Value::Integer.
Sourcepub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
Returns the boolean if this is a Value::Boolean.
Sourcepub fn as_string_list(&self) -> Option<&[String]>
pub fn as_string_list(&self) -> Option<&[String]>
Returns the elements if this is a Value::StringList.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Value
impl<'de> Deserialize<'de> for Value
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 Eq for Value
impl StructuralPartialEq for Value
Auto Trait Implementations§
impl Forget for Value
impl Freeze for Value
impl Move for Value
impl RefUnwindSafe for Value
impl Send for Valuewhere
RawVecInner: Send,
impl Sync for Valuewhere
RawVecInner: Sync,
impl Unpin for Value
impl UnsafeUnpin for Valuewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
impl UnwindSafe for Valuewhere
RawVecInner: UnwindSafe,
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
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>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.