toml_edit

Enum Item

Source
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

Source

pub fn or_insert(&mut self, item: Item) -> &mut Item

Sets self to the given item if self is none and returns a mutable reference to self.

Source§

impl Item

Downcasting

Source

pub fn type_name(&self) -> &'static str

Text description of value type

Source

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 and self 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.
Source

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 and self 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.
Source

pub fn as_value(&self) -> Option<&Value>

Casts self to value.

Source

pub fn as_table(&self) -> Option<&Table>

Casts self to table.

Source

pub fn as_array_of_tables(&self) -> Option<&ArrayOfTables>

Casts self to array of tables.

Source

pub fn as_value_mut(&mut self) -> Option<&mut Value>

Casts self to mutable value.

Source

pub fn as_table_mut(&mut self) -> Option<&mut Table>

Casts self to mutable table.

Source

pub fn as_array_of_tables_mut(&mut self) -> Option<&mut ArrayOfTables>

Casts self to mutable array of tables.

Source

pub fn into_value(self) -> Result<Value, Self>

Casts self to value.

Source

pub fn make_value(&mut self)

In-place convert to a value

Source

pub fn into_table(self) -> Result<Table, Self>

Casts self to table.

Source

pub fn into_array_of_tables(self) -> Result<ArrayOfTables, Self>

Casts self to array of tables.

Source

pub fn is_value(&self) -> bool

Returns true if self is a value.

Source

pub fn is_table(&self) -> bool

Returns true if self is a table.

Source

pub fn is_array_of_tables(&self) -> bool

Returns true if self is an array of tables.

Source

pub fn is_none(&self) -> bool

Returns true if self is None.

Source

pub fn as_integer(&self) -> Option<i64>

Casts self to integer.

Source

pub fn is_integer(&self) -> bool

Returns true if self is an integer.

Source

pub fn as_float(&self) -> Option<f64>

Casts self to float.

Source

pub fn is_float(&self) -> bool

Returns true if self is a float.

Source

pub fn as_bool(&self) -> Option<bool>

Casts self to boolean.

Source

pub fn is_bool(&self) -> bool

Returns true if self is a boolean.

Source

pub fn as_str(&self) -> Option<&str>

Casts self to str.

Source

pub fn is_str(&self) -> bool

Returns true if self is a string.

Source

pub fn as_datetime(&self) -> Option<&Datetime>

Casts self to date-time.

Source

pub fn is_datetime(&self) -> bool

Returns true if self is a date-time.

Source

pub fn as_array(&self) -> Option<&Array>

Casts self to array.

Source

pub fn as_array_mut(&mut self) -> Option<&mut Array>

Casts self to mutable array.

Source

pub fn is_array(&self) -> bool

Returns true if self is an array.

Source

pub fn as_inline_table(&self) -> Option<&InlineTable>

Casts self to inline table.

Source

pub fn as_inline_table_mut(&mut self) -> Option<&mut InlineTable>

Casts self to mutable inline table.

Source

pub fn is_inline_table(&self) -> bool

Returns true if self is an inline table.

Source

pub fn as_table_like(&self) -> Option<&dyn TableLike>

Casts self to either a table or an inline table.

Source

pub fn as_table_like_mut(&mut self) -> Option<&mut dyn TableLike>

Casts self to either a table or an inline table.

Source

pub fn is_table_like(&self) -> bool

Returns true if self is either a table, or an inline table.

Source

pub fn span(&self) -> Option<Range<usize>>

The location within the original document

This generally requires an ImDocument.

Trait Implementations§

Source§

impl Clone for Item

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Item

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Item

Source§

fn default() -> Item

Returns the “default value” for a type. Read more
Source§

impl Display for Item

Available on crate feature display only.
Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'b> From<&'b Item> for Item

Source§

fn from(s: &'b Item) -> Self

Converts to this type from the input type.
Source§

impl<V: Into<Value>> From<V> for Item

Source§

fn from(s: V) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Item

Available on crate feature parse only.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a value from a &str

Source§

type Err = TomlError

The associated error which can be returned from parsing.
Source§

impl<I> Index<I> for Item
where I: Index,

Source§

type Output = Item

The returned type after indexing.
Source§

fn index(&self, index: I) -> &Item

Performs the indexing (container[index]) operation. Read more
Source§

impl<I> IndexMut<I> for Item
where I: Index,

Source§

fn index_mut(&mut self, index: I) -> &mut Item

Performs the mutable indexing (container[index]) operation. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

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 bytes
  • Value: 176 bytes
  • Table: 176 bytes
  • ArrayOfTables: 56 bytes