[−][src]Enum toml::Value
Representation of a TOML value.
Variants
String(String)
Integer(i64)
Float(f64)
Boolean(bool)
Datetime(String)
Array(Array)
Table(Table)
Implementations
impl Value
[src]
pub fn same_type(&self, other: &Value) -> bool
[src]
Tests whether this and another value have the same type.
pub fn type_str(&self) -> &'static str
[src]
Returns a human-readable representation of the type of this value.
pub fn as_str(&self) -> Option<&str>
[src]
Extracts the string of this value if it is a string.
pub fn as_integer(&self) -> Option<i64>
[src]
Extracts the integer value if it is an integer.
pub fn as_float(&self) -> Option<f64>
[src]
Extracts the float value if it is a float.
pub fn as_bool(&self) -> Option<bool>
[src]
Extracts the boolean value if it is a boolean.
pub fn as_datetime(&self) -> Option<&str>
[src]
Extracts the datetime value if it is a datetime.
Note that a parsed TOML value will only contain ISO 8601 dates. An example date is:
1979-05-27T07:32:00Z
pub fn as_slice(&self) -> Option<&[Value]>
[src]
Extracts the array value if it is an array.
pub fn as_table(&self) -> Option<&Table>
[src]
Extracts the table value if it is a table.
pub fn lookup<'a>(&'a self, path: &'a str) -> Option<&'a Value>
[src]
Lookups for value at specified path.
Uses '.' as a path separator.
Note: arrays have zero-based indexes.
Note: empty path returns self.
let toml = r#" [test] foo = "bar" [[values]] foo = "baz" [[values]] foo = "qux" "#; let value: toml::Value = toml.parse().unwrap(); let foo = value.lookup("test.foo").unwrap(); assert_eq!(foo.as_str().unwrap(), "bar"); let foo = value.lookup("values.1.foo").unwrap(); assert_eq!(foo.as_str().unwrap(), "qux"); let no_bar = value.lookup("test.bar"); assert_eq!(no_bar.is_none(), true);
pub fn lookup_mut(&mut self, path: &str) -> Option<&mut Value>
[src]
Lookups for mutable value at specified path.
Uses '.' as a path separator.
Note: arrays have zero-based indexes.
Note: empty path returns self.
let toml = r#" [test] foo = "bar" [[values]] foo = "baz" [[values]] foo = "qux" "#; let mut value: toml::Value = toml.parse().unwrap(); { let string = value.lookup_mut("test.foo").unwrap(); assert_eq!(string, &mut toml::Value::String(String::from("bar"))); *string = toml::Value::String(String::from("foo")); } let result = value.lookup_mut("test.foo").unwrap(); assert_eq!(result.as_str().unwrap(), "foo");
Trait Implementations
impl Clone for Value
[src]
impl Debug for Value
[src]
impl Display for Value
[src]
impl Encodable for Value
[src]
impl FromStr for Value
[src]
type Err = Vec<ParserError>
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Value, Vec<ParserError>>
[src]
impl PartialEq<Value> for Value
[src]
impl StructuralPartialEq for Value
[src]
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
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,