Enum toml_edit::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 iff 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 iff 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 iff 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 iff 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 iff 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 iff 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 iff 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 ");

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

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) -> Selfwhere 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) -> Selfwhere I: IntoIterator<Item = V>,

Creates a value from an iterator. Read more
source§

impl FromStr for Value

source§

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

Parses a value from a &str

§

type Err = TomlError

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

impl<'de> IntoDeserializer<'de, Error> for Value

§

type Deserializer = ValueDeserializer

The type of the deserializer being converted into.
source§

fn into_deserializer(self) -> Self::Deserializer

Convert this value into a deserializer.

Auto Trait Implementations§

§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere T: Clone,

§

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 Twhere 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.