pub enum Item {
None,
Value(Value),
Table(Table),
ArrayOfTables(ArrayOfTables),
}
Expand description
Type representing either a value, a table, an array of tables, or none.
Variants§
None
Type representing none.
Value(Value)
Type representing value.
Table(Table)
Type representing table.
ArrayOfTables(ArrayOfTables)
Type representing array of tables.
Implementations§
Source§impl Item
impl Item
Downcasting
Sourcepub fn get<I: Index>(&self, index: I) -> Option<&Item>
pub fn get<I: Index>(&self, index: I) -> Option<&Item>
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 andself
is an array or a number. - The given key does not exist in the map or the given index is not within the bounds of the array.
Sourcepub fn get_mut<I: Index>(&mut self, index: I) -> Option<&mut Item>
pub fn get_mut<I: Index>(&mut self, index: I) -> Option<&mut Item>
Mutably 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 andself
is an array or a number. - The given key does not exist in the map or the given index is not within the bounds of the array.
Sourcepub fn as_array_of_tables(&self) -> Option<&ArrayOfTables>
pub fn as_array_of_tables(&self) -> Option<&ArrayOfTables>
Casts self
to array of tables.
Sourcepub fn as_value_mut(&mut self) -> Option<&mut Value>
pub fn as_value_mut(&mut self) -> Option<&mut Value>
Casts self
to mutable value.
Sourcepub fn as_table_mut(&mut self) -> Option<&mut Table>
pub fn as_table_mut(&mut self) -> Option<&mut Table>
Casts self
to mutable table.
Sourcepub fn as_array_of_tables_mut(&mut self) -> Option<&mut ArrayOfTables>
pub fn as_array_of_tables_mut(&mut self) -> Option<&mut ArrayOfTables>
Casts self
to mutable array of tables.
Sourcepub fn into_value(self) -> Result<Value, Self>
pub fn into_value(self) -> Result<Value, Self>
Casts self
to value.
Sourcepub fn make_value(&mut self)
pub fn make_value(&mut self)
In-place convert to a value
Sourcepub fn into_table(self) -> Result<Table, Self>
pub fn into_table(self) -> Result<Table, Self>
Casts self
to table.
Sourcepub fn into_array_of_tables(self) -> Result<ArrayOfTables, Self>
pub fn into_array_of_tables(self) -> Result<ArrayOfTables, Self>
Casts self
to array of tables.
Sourcepub fn is_array_of_tables(&self) -> bool
pub fn is_array_of_tables(&self) -> bool
Returns true if self
is an array of tables.
Sourcepub fn as_integer(&self) -> Option<i64>
pub fn as_integer(&self) -> Option<i64>
Casts self
to integer.
Sourcepub fn is_integer(&self) -> bool
pub fn is_integer(&self) -> bool
Returns true if self
is an integer.
Sourcepub fn as_datetime(&self) -> Option<&Datetime>
pub fn as_datetime(&self) -> Option<&Datetime>
Casts self
to date-time.
Sourcepub fn is_datetime(&self) -> bool
pub fn is_datetime(&self) -> bool
Returns true if self
is a date-time.
Sourcepub fn as_array_mut(&mut self) -> Option<&mut Array>
pub fn as_array_mut(&mut self) -> Option<&mut Array>
Casts self
to mutable array.
Sourcepub fn as_inline_table(&self) -> Option<&InlineTable>
pub fn as_inline_table(&self) -> Option<&InlineTable>
Casts self
to inline table.
Sourcepub fn as_inline_table_mut(&mut self) -> Option<&mut InlineTable>
pub fn as_inline_table_mut(&mut self) -> Option<&mut InlineTable>
Casts self
to mutable inline table.
Sourcepub fn is_inline_table(&self) -> bool
pub fn is_inline_table(&self) -> bool
Returns true if self
is an inline table.
Sourcepub fn as_table_like(&self) -> Option<&dyn TableLike>
pub fn as_table_like(&self) -> Option<&dyn TableLike>
Casts self
to either a table or an inline table.
Sourcepub fn as_table_like_mut(&mut self) -> Option<&mut dyn TableLike>
pub fn as_table_like_mut(&mut self) -> Option<&mut dyn TableLike>
Casts self
to either a table or an inline table.
Sourcepub fn is_table_like(&self) -> bool
pub fn is_table_like(&self) -> bool
Returns true if self
is either a table, or an inline table.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Item
impl RefUnwindSafe for Item
impl Send for Item
impl Sync for Item
impl Unpin for Item
impl UnwindSafe for Item
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 176 bytes
Size for each variant:
None
: 0 bytesValue
: 176 bytesTable
: 176 bytesArrayOfTables
: 56 bytes