pub enum Value {
Scalar(Scalar),
Array(Array),
Object(Object),
Nil,
Empty,
Blank,
}Expand description
An enum to represent different value types
Variants§
Scalar(Scalar)
A scalar value.
Array(Array)
A sequence of Values.
Object(Object)
A sequence of key/Value pairs.
Nil
Nothing.
Empty
No content.
Blank
Evaluates to empty string.
Implementations§
Source§impl Value
impl Value
Sourcepub fn array<I: IntoIterator<Item = Self>>(iter: I) -> Self
pub fn array<I: IntoIterator<Item = Self>>(iter: I) -> Self
Create as an Array.
Sourcepub fn source(&self) -> ValueSource<'_>
pub fn source(&self) -> ValueSource<'_>
A Display for a Scalar as source code.
Sourcepub fn render(&self) -> ValueRendered<'_>
pub fn render(&self) -> ValueRendered<'_>
A Display for a Value rendered for the user.
Sourcepub fn into_scalar(self) -> Option<Scalar>
pub fn into_scalar(self) -> Option<Scalar>
Extracts the scalar value if it is a scalar.
Sourcepub fn as_array_mut(&mut self) -> Option<&mut Array>
pub fn as_array_mut(&mut self) -> Option<&mut Array>
Extracts the array value if it is an array.
Sourcepub fn into_array(self) -> Option<Array>
pub fn into_array(self) -> Option<Array>
Extracts the array value if it is an array.
Sourcepub fn as_object_mut(&mut self) -> Option<&mut Object>
pub fn as_object_mut(&mut self) -> Option<&mut Object>
Extracts the object value if it is a object.
Sourcepub fn into_object(self) -> Option<Object>
pub fn into_object(self) -> Option<Object>
Extracts the object value if it is a object.
Sourcepub fn is_default(&self) -> bool
pub fn is_default(&self) -> bool
Whether a default constructed value.
Sourcepub fn contains_key(&self, index: &Scalar) -> bool
pub fn contains_key(&self, index: &Scalar) -> bool
Access a contained Value.
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
Source§impl PartialOrd for Value
impl PartialOrd for Value
impl Eq 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 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,
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