Enum serde_dhall::SimpleValue [−][src]
A value of the kind that can be decoded by serde_dhall
, e.g. { x = True, y = [1, 2, 3] }
.
This can be obtained with from_str()
or from_file()
.
It can also be deserialized into Rust types with from_simple_value()
.
Examples
use std::collections::BTreeMap; use serde::Deserialize; use serde_dhall::{from_simple_value, NumKind, SimpleValue}; #[derive(Debug, PartialEq, Eq, Deserialize)] struct Foo { x: bool, y: Vec<u64>, } let value: SimpleValue = serde_dhall::from_str("{ x = True, y = [1, 2, 3] }").parse()?; assert_eq!( value, SimpleValue::Record({ let mut r = BTreeMap::new(); r.insert( "x".to_string(), SimpleValue::Num(NumKind::Bool(true)) ); r.insert( "y".to_string(), SimpleValue::List(vec![ SimpleValue::Num(NumKind::Natural(1)), SimpleValue::Num(NumKind::Natural(2)), SimpleValue::Num(NumKind::Natural(3)), ]) ); r }) ); let foo: Foo = from_simple_value(value)?; assert_eq!( foo, Foo { x: true, y: vec![1, 2, 3] } );
use std::collections::BTreeMap; use serde_dhall::{NumKind, SimpleValue}; let value: SimpleValue = serde_dhall::from_str("{ x = 1, y = 2 }").parse()?; let mut map = BTreeMap::new(); map.insert("x".to_string(), SimpleValue::Num(NumKind::Natural(1))); map.insert("y".to_string(), SimpleValue::Num(NumKind::Natural(2))); assert_eq!(value, SimpleValue::Record(map));
Variants
Num(NumKind)
Numbers and booleans - True
, 1
, +2
, 3.24
Text(String)
A string of text - "Hello world!"
Optional(Option<Box<SimpleValue>>)
An optional value - Some e
, None
List(Vec<SimpleValue>)
A list of values - [a, b, c, d, e]
Record(BTreeMap<String, SimpleValue>)
A record value - { k1 = v1, k2 = v2 }
Union(String, Option<Box<SimpleValue>>)
A union value (both the name of the variant and the variant's value) - Left e
Trait Implementations
impl Clone for SimpleValue
[src]
fn clone(&self) -> SimpleValue
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for SimpleValue
[src]
impl<'de> Deserialize<'de> for SimpleValue
[src]
fn deserialize<D>(deserializer: D) -> Result<SimpleValue, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl Eq for SimpleValue
[src]
impl PartialEq<SimpleValue> for SimpleValue
[src]
fn eq(&self, other: &SimpleValue) -> bool
[src]
fn ne(&self, other: &SimpleValue) -> bool
[src]
impl Serialize for SimpleValue
[src]
impl StructuralEq for SimpleValue
[src]
impl StructuralPartialEq for SimpleValue
[src]
Auto Trait Implementations
impl RefUnwindSafe for SimpleValue
[src]
impl Send for SimpleValue
[src]
impl Sync for SimpleValue
[src]
impl Unpin for SimpleValue
[src]
impl UnwindSafe for SimpleValue
[src]
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,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
pub fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
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.
pub 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>,