pub enum Value {
Null,
Bool(bool),
Number(Number),
String(String),
Array(Vec<Value>),
Object(Vec<(String, Value)>),
}Expand description
Represents Value.
Variants§
Null
Represents Null.
Bool(bool)
Represents Bool.
Number(Number)
Represents Number.
String(String)
Represents String.
Array(Vec<Value>)
Represents Array.
Object(Vec<(String, Value)>)
Represents Object.
Implementations§
Source§impl Value
impl Value
Sourcepub fn object(entries: Vec<(&str, Value)>) -> Value
pub fn object(entries: Vec<(&str, Value)>) -> Value
Creates an object from string keys and values.
Sourcepub fn get(&self, key: &str) -> Option<&Value>
pub fn get(&self, key: &str) -> Option<&Value>
Value for key, or None – a missing key, or self not being an
object at all. Reading a field off a non-object is None, not an error.
Sourcepub fn as_object(&self) -> Option<&[(String, Value)]>
pub fn as_object(&self) -> Option<&[(String, Value)]>
Returns the object entries, or None for another value variant.
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Some only for the String variant – deliberately does NOT coerce
numbers or bools to text. find_in_manifest’s hay build and its
source default both rely on this narrower behavior; a non-string
purpose/source (not produced by any real manifest writer) is simply
treated as absent.
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 StructuralPartialEq for Value
Auto Trait Implementations§
impl Freeze for Value
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnsafeUnpin for Value
impl UnwindSafe for Value
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<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> ⓘ
Converts
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> ⓘ
Converts
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