Enum serde_content::Value

source ·
pub enum Value<'a> {
    Unit,
    Bool(bool),
    Number(Number),
    Char(char),
    String(Cow<'a, str>),
    Bytes(Cow<'a, [u8]>),
    Seq(Vec<Value<'a>>),
    Map(Vec<(Value<'a>, Value<'a>)>),
    Option(Option<Box<Value<'a>>>),
    Struct(Box<Struct<'a>>),
    Enum(Box<Enum<'a>>),
    Tuple(Vec<Value<'a>>),
}
Expand description

Represents any valid Rust value.

Variants§

§

Unit

Represents the Rust unit type, ().

§

Bool(bool)

Represents a Rust boolean.

§

Number(Number)

Represents any Rust number.

§

Char(char)

Represents a Rust character.

§

String(Cow<'a, str>)

Represents a Rust string.

§

Bytes(Cow<'a, [u8]>)

Represents a Rust byte array.

§

Seq(Vec<Value<'a>>)

Represents an array of Rust values.

§

Map(Vec<(Value<'a>, Value<'a>)>)

Represents a map of Rust values.

§

Option(Option<Box<Value<'a>>>)

Represents optional Rust values.

§

Struct(Box<Struct<'a>>)

Represents a Rust struct.

§

Enum(Box<Enum<'a>>)

Represents a Rust enum.

§

Tuple(Vec<Value<'a>>)

Represents a Rust tuple.

Implementations§

source§

impl Value<'_>

source

pub fn into_owned(self) -> Value<'static>

Moves data where possible or otherwise clones it into an owned object.

Trait Implementations§

source§

impl<'a> Clone for Value<'a>

source§

fn clone(&self) -> Value<'a>

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<'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> Deserialize<'de> for Value<'static>

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> From<&'a [u8]> for Value<'a>

source§

fn from(value: &'a [u8]) -> Self

Converts to this type from the input type.
source§

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

source§

fn from(value: &'a String) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a Vec<u8>> for Value<'a>

source§

fn from(value: &'a Vec<u8>) -> Self

Converts to this type from the input type.
source§

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

source§

fn from(value: &'a str) -> Self

Converts to this type from the input type.
source§

impl From<()> for Value<'static>

source§

fn from(_: ()) -> Self

Converts to this type from the input type.
source§

impl<'a> From<Cow<'a, str>> for Value<'a>

source§

fn from(value: Cow<'a, str>) -> Self

Converts to this type from the input type.
source§

impl From<String> for Value<'static>

source§

fn from(value: String) -> Self

Converts to this type from the input type.
source§

impl<T> From<T> for Value<'static>
where T: Into<Number>,

source§

fn from(value: T) -> Self

Converts to this type from the input type.
source§

impl From<Vec<u8>> for Value<'static>

source§

fn from(value: Vec<u8>) -> Self

Converts to this type from the input type.
source§

impl From<bool> for Value<'static>

source§

fn from(value: bool) -> Self

Converts to this type from the input type.
source§

impl From<char> for Value<'static>

source§

fn from(value: char) -> Self

Converts to this type from the input type.
source§

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

§

type Deserializer = Deserializer<'de>

The type of the deserializer being converted into.
source§

fn into_deserializer(self) -> Self::Deserializer

Convert this value into a deserializer.
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> PartialOrd for Value<'a>

source§

fn partial_cmp(&self, other: &Value<'a>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
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 Unexpected for Value<'_>

source§

fn unexpected(self, expected: Expected) -> Error

Consumes the type and returns an error.
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> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬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,

§

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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>,