Enum Value

Source
pub enum Value<'a> {
    Literal(Cow<'a, str>),
    DoubleQuotedString(Cow<'a, str>),
    SingleQuotedString(Cow<'a, str>),
    Number(f64),
    Map(HashMap<Key<'a>, Value<'a>>),
    List(Vec<Value<'a>>),
}
Expand description

参数值

Variants§

§

Literal(Cow<'a, str>)

字面值

literal

§

DoubleQuotedString(Cow<'a, str>)

双引号字符串

"abcd"

§

SingleQuotedString(Cow<'a, str>)

单引号字符串

'abcd'

§

Number(f64)

数值

12345

§

Map(HashMap<Key<'a>, Value<'a>>)

Key-Value值列表

(key=value key=value)

§

List(Vec<Value<'a>>)

多值列表

  • ("abcd", "abcd")
  • (("abcd", abcd))

Implementations§

Source§

impl<'a> Value<'a>

Source

pub fn is_literal(&self) -> bool

类型是否为字面值

Source

pub fn is_string(&self) -> bool

类型是否为字符串

Source

pub fn is_number(&self) -> bool

类型是否为数值

Source

pub fn is_map(&self) -> bool

类型是否为Key-Value值列表

Source

pub fn is_list(&self) -> bool

类型是否为多值列表

Source

pub fn as_literal(&self) -> Option<&Cow<'a, str>>

获取字面值

Source

pub fn as_string(&self) -> Option<&Cow<'a, str>>

获取字符串

Source

pub fn as_number(&self) -> Option<f64>

获取数值

Source

pub fn as_map(&self) -> Option<&HashMap<Key<'a>, Value<'a>>>

获取Key-Value值列表

Source

pub fn as_list(&self) -> Option<&Vec<Value<'a>>>

获取多值列表

Trait Implementations§

Source§

impl<'a> Debug for Value<'a>

Source§

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

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

impl<'de, 'a> Deserialize<'de> for Value<'a>

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'a> Display for Value<'a>

Source§

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

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

impl<'a> PartialEq for Value<'a>

Source§

fn eq(&self, other: &Value<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Serialize for Value<'a>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'a> StructuralPartialEq for Value<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Value<'a>

§

impl<'a> RefUnwindSafe for Value<'a>

§

impl<'a> Send for Value<'a>

§

impl<'a> Sync for Value<'a>

§

impl<'a> Unpin for Value<'a>

§

impl<'a> UnwindSafe for Value<'a>

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> 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> ToString for T
where T: Display + ?Sized,

Source§

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,