Enum DeValue
pub enum DeValue<'i>
Representation of a TOML value.
Variants
-
String(DeString<'i>) 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(DeTable<'i>) Represents a TOML table
Implementations
impl<'i> DeValue<'i>
fn parse(input: &'i str) -> Result<Spanned<Self>, Error>Parse a TOML value
fn parse_recoverable(input: &'i str) -> (Spanned<Self>, Vec<Error>)Parse a TOML value, with best effort recovery on error
fn make_owned(&mut self)Ensure no data is borrowed
fn get<I: Index>(&self, index: I) -> Option<&Spanned<Self>>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
Noneif the type ofselfdoes not match the type of the index, for example if the index is a string andselfis an array or a number. Also returnsNoneif the given key does not exist in the map or the given index is not within the bounds of the array.fn as_integer(&self) -> Option<&DeInteger<'i>>Extracts the integer value if it is an integer.
fn is_integer(&self) -> boolTests whether this value is an integer.
fn as_float(&self) -> Option<&DeFloat<'i>>Extracts the float value if it is a float.
fn is_float(&self) -> boolTests whether this value is a float.
fn as_bool(&self) -> Option<bool>Extracts the boolean value if it is a boolean.
fn is_bool(&self) -> boolTests whether this value is a boolean.
fn as_str(&self) -> Option<&str>Extracts the string of this value if it is a string.
fn is_str(&self) -> boolTests if this value is a string.
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:00Zfn is_datetime(&self) -> boolTests whether this value is a datetime.
fn as_array(&self) -> Option<&DeArray<'i>>Extracts the array value if it is an array.
fn is_array(&self) -> boolTests whether this value is an array.
fn as_table(&self) -> Option<&DeTable<'i>>Extracts the table value if it is a table.
fn is_table(&self) -> boolTests whether this value is a table.
fn same_type(&self, other: &DeValue<'_>) -> boolTests whether this and another value have the same type.
fn type_str(&self) -> &'static strReturns a human-readable representation of the type of this value.
Trait Implementations
impl<'i> Clone for DeValue<'i>
fn clone(&self) -> Self
impl<'i> Debug for DeValue<'i>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<I> Index<I> for DeValue<'_>
where
I: Index,
type Output = Spanned<DeValue<'_>>;fn index(&self, index: I) -> &Spanned<Self>