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,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)