Enum toml_edit::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 T)

🔬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.