toml_edit

Enum Value

Source
pub enum Value {
    String(Formatted<String>),
    Integer(Formatted<i64>),
    Float(Formatted<f64>),
    Boolean(Formatted<bool>),
    Datetime(Formatted<Datetime>),
    Array(Array),
    InlineTable(InlineTable),
}
Expand description

Representation of a TOML Value (as part of a Key/Value Pair).

Variants§

§

String(Formatted<String>)

A string value.

§

Integer(Formatted<i64>)

A 64-bit integer value.

§

Float(Formatted<f64>)

A 64-bit float value.

§

Boolean(Formatted<bool>)

A boolean value.

§

Datetime(Formatted<Datetime>)

An RFC 3339 formatted date-time with offset.

§

Array(Array)

An inline array of values.

§

InlineTable(InlineTable)

An inline table of key/value pairs.

Implementations§

Source§

impl Value

Downcasting

Source

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

Text description of value type

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_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_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§

impl Value

Source

pub fn decor_mut(&mut self) -> &mut Decor

Get the decoration of the value.

§Example
let v = toml_edit::Value::from(true);
assert_eq!(v.decor().suffix(), None);
Source

pub fn decor(&self) -> &Decor

Get the decoration of the value.

§Example
let v = toml_edit::Value::from(true);
assert_eq!(v.decor().suffix(), None);
Source

pub fn decorated( self, prefix: impl Into<RawString>, suffix: impl Into<RawString>, ) -> Self

Sets the prefix and the suffix for value.

§Example
let mut v = toml_edit::Value::from(42);
assert_eq!(&v.to_string(), "42");
let d = v.decorated(" ", " ");
assert_eq!(&d.to_string(), " 42 ");
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 Value

Source§

fn clone(&self) -> Value

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 Value

Source§

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

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

impl Display for Value

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 InternalString> for Value

Source§

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

Converts to this type from the input type.
Source§

impl<'b> From<&'b String> for Value

Source§

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

Converts to this type from the input type.
Source§

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

Source§

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

Converts to this type from the input type.
Source§

impl<'b> From<&'b str> for Value

Source§

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

Converts to this type from the input type.
Source§

impl From<Array> for Value

Source§

fn from(array: Array) -> Self

Converts to this type from the input type.
Source§

impl From<Date> for Value

Source§

fn from(d: Date) -> Self

Converts to this type from the input type.
Source§

impl From<Datetime> for Value

Source§

fn from(d: Datetime) -> Self

Converts to this type from the input type.
Source§

impl From<InlineTable> for Value

Source§

fn from(table: InlineTable) -> Self

Converts to this type from the input type.
Source§

impl From<InternalString> for Value

Source§

fn from(s: InternalString) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Value

Source§

fn from(s: String) -> Self

Converts to this type from the input type.
Source§

impl From<Time> for Value

Source§

fn from(d: Time) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Value

Source§

fn from(b: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Value

Source§

fn from(f: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Value

Source§

fn from(i: i64) -> Self

Converts to this type from the input type.
Source§

impl<K: Into<Key>, V: Into<Value>> FromIterator<(K, V)> for Value

Source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = (K, V)>,

Creates a value from an iterator. Read more
Source§

impl<V: Into<Value>> FromIterator<V> for Value

Source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = V>,

Creates a value from an iterator. Read more
Source§

impl FromStr for Value

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.

Auto Trait Implementations§

§

impl Freeze for Value

§

impl RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl UnwindSafe for Value

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:

  • String: 104 bytes
  • Integer: 88 bytes
  • Float: 88 bytes
  • Boolean: 88 bytes
  • Datetime: 104 bytes
  • Array: 136 bytes
  • InlineTable: 176 bytes