pub enum DeValue<'i> {
String(Cow<'i, str>),
Integer(DeInteger<'i>),
Float(DeFloat<'i>),
Boolean(bool),
Datetime(Datetime),
Array(DeArray<'i>),
Table(Map<Spanned<Cow<'i, str>>, Spanned<DeValue<'i>>>),
}
Expand description
Representation of a TOML value.
Variants§
String(Cow<'i, str>)
Represents a TOML string
Integer(DeInteger<'i>)
Represents a TOML integer
Float(DeFloat<'i>)
Represents a TOML float
Boolean(bool)
Represents a TOML boolean
Datetime(Datetime)
Represents a TOML datetime
Array(DeArray<'i>)
Represents a TOML array
Table(Map<Spanned<Cow<'i, str>>, Spanned<DeValue<'i>>>)
Represents a TOML table
Implementations§
Source§impl<'i> DeValue<'i>
impl<'i> DeValue<'i>
Sourcepub fn parse_recoverable(input: &'i str) -> (Spanned<DeValue<'i>>, Vec<Error>)
pub fn parse_recoverable(input: &'i str) -> (Spanned<DeValue<'i>>, Vec<Error>)
Parse a TOML value, with best effort recovery on error
Sourcepub fn make_owned(&mut self)
pub fn make_owned(&mut self)
Ensure no data is borrowed
Sourcepub fn get<I>(&self, index: I) -> Option<&Spanned<DeValue<'i>>>where
I: Index,
pub fn get<I>(&self, index: I) -> Option<&Spanned<DeValue<'i>>>where
I: Index,
Index into a TOML array or map. A string index can be used to access a value in a map, and a usize index can be used to access an element of an array.
Returns None
if the type of self
does not match the type of the
index, for example if the index is a string and self
is an array or a
number. Also returns None
if the given key does not exist in the map
or the given index is not within the bounds of the array.
Sourcepub fn as_integer(&self) -> Option<&DeInteger<'i>>
pub fn as_integer(&self) -> Option<&DeInteger<'i>>
Extracts the integer value if it is an integer.
Sourcepub fn is_integer(&self) -> bool
pub fn is_integer(&self) -> bool
Tests whether this value is an integer.
Sourcepub fn as_datetime(&self) -> Option<&Datetime>
pub fn as_datetime(&self) -> Option<&Datetime>
Extracts the datetime value if it is a datetime.
Note that a parsed TOML value will only contain ISO 8601 dates. An example date is:
1979-05-27T07:32:00Z
Sourcepub fn is_datetime(&self) -> bool
pub fn is_datetime(&self) -> bool
Tests whether this value is a datetime.
Sourcepub fn as_table(
&self,
) -> Option<&Map<Spanned<Cow<'i, str>>, Spanned<DeValue<'i>>>>
pub fn as_table( &self, ) -> Option<&Map<Spanned<Cow<'i, str>>, Spanned<DeValue<'i>>>>
Extracts the table value if it is a table.