Value

Enum Value 

Source
pub enum Value<'s> {
    I64(i64),
    U64(u64),
    Float(OrderedFloat<f64>),
    Str(CowStr<'s>),
    Bytes(CowBytes<'s>),
    Null,
    Bool(bool),
    Array(Array<'s>),
    Map(Map<'s>),
}
Expand description

Think serde_json::Value, but with a small string optimization, copy-on-write strings, etc. Might include other value types later.

Variants§

§

I64(i64)

§

U64(u64)

§

Float(OrderedFloat<f64>)

§

Str(CowStr<'s>)

§

Bytes(CowBytes<'s>)

§

Null

§

Bool(bool)

§

Array(Array<'s>)

§

Map(Map<'s>)

Implementations§

Source§

impl Value<'_>

Source

pub fn value_type(&self) -> ValueType

Returns the ValueType for a given Value.

Source§

impl<'s> Value<'s>

Source

pub fn as_map(&self) -> Result<&Map<'s>, MerdeError<'static>>

Source

pub fn into_map(self) -> Result<Map<'s>, MerdeError<'static>>

Source

pub fn as_array(&self) -> Result<&Array<'s>, MerdeError<'static>>

Source

pub fn into_array(self) -> Result<Array<'s>, MerdeError<'static>>

Source

pub fn as_str(&self) -> Result<&CowStr<'s>, MerdeError<'static>>

Source

pub fn into_str(self) -> Result<CowStr<'s>, MerdeError<'static>>

Source

pub fn as_bytes(&self) -> Result<&CowBytes<'s>, MerdeError<'static>>

Source

pub fn into_bytes(self) -> Result<CowBytes<'s>, MerdeError<'static>>

Source

pub fn as_i64(&self) -> Result<i64, MerdeError<'static>>

Source

pub fn as_u64(&self) -> Result<u64, MerdeError<'static>>

Source

pub fn as_f64(&self) -> Result<f64, MerdeError<'static>>

Trait Implementations§

Source§

impl<'s> Clone for Value<'s>

Source§

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

Returns a duplicate 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<'s> Debug for Value<'s>

Source§

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

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

impl<'s> Deserialize<'s> for Value<'s>

Source§

async fn deserialize( de: &mut dyn DynDeserializer<'s>, ) -> Result<Self, MerdeError<'s>>

Source§

fn from_option( value: Option<Self>, field_name: CowStr<'s>, ) -> Result<Self, MerdeError<'s>>

Source§

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

Source§

fn from(v: &'s String) -> Self

Converts to this type from the input type.
Source§

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

Source§

fn from(v: &'s str) -> Self

Converts to this type from the input type.
Source§

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

Source§

fn from(_: ()) -> Self

Converts to this type from the input type.
Source§

impl<'s> From<Array<'s>> for Value<'s>

Source§

fn from(v: Array<'s>) -> Self

Converts to this type from the input type.
Source§

impl<'s> From<CowBytes<'s>> for Value<'s>

Source§

fn from(v: CowBytes<'s>) -> Self

Converts to this type from the input type.
Source§

impl<'s> From<CowStr<'s>> for Value<'s>

Source§

fn from(v: CowStr<'s>) -> Self

Converts to this type from the input type.
Source§

impl<'s> From<HashMap<CowStr<'s>, Value<'s>>> for Value<'s>

Source§

fn from(v: HashMap<CowStr<'s>, Value<'s>>) -> Self

Converts to this type from the input type.
Source§

impl<'s> From<Map<'s>> for Value<'s>

Source§

fn from(v: Map<'s>) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Value<'_>

Source§

fn from(v: String) -> Self

Converts to this type from the input type.
Source§

impl<'s> From<Vec<Value<'s>>> for Value<'s>

Source§

fn from(v: Vec<Value<'s>>) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Value<'_>

Source§

fn from(v: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for Value<'_>

Source§

fn from(v: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Value<'_>

Source§

fn from(v: f64) -> Self

Converts to this type from the input type.
Source§

impl<'s> From<i16> for Value<'s>

Source§

fn from(v: i16) -> Self

Converts to this type from the input type.
Source§

impl<'s> From<i32> for Value<'s>

Source§

fn from(v: i32) -> Self

Converts to this type from the input type.
Source§

impl<'s> From<i64> for Value<'s>

Source§

fn from(v: i64) -> Self

Converts to this type from the input type.
Source§

impl<'s> From<i8> for Value<'s>

Source§

fn from(v: i8) -> Self

Converts to this type from the input type.
Source§

impl<'s> From<u16> for Value<'s>

Source§

fn from(v: u16) -> Self

Converts to this type from the input type.
Source§

impl<'s> From<u32> for Value<'s>

Source§

fn from(v: u32) -> Self

Converts to this type from the input type.
Source§

impl<'s> From<u64> for Value<'s>

Source§

fn from(v: u64) -> Self

Converts to this type from the input type.
Source§

impl<'s> From<u8> for Value<'s>

Source§

fn from(v: u8) -> Self

Converts to this type from the input type.
Source§

impl<'s> Hash for Value<'s>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl IntoStatic for Value<'_>

Source§

type Output = Value<'static>

The “owned” variant of the type. For Cow<'a, str>, this is Cow<'static, str>, for example.
Source§

fn into_static(self) -> <Self as IntoStatic>::Output

Turns the value into an “owned” variant, which can then be returned, moved, etc. Read more
Source§

impl<'s> PartialEq for Value<'s>

Source§

fn eq(&self, other: &Value<'s>) -> 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 Serialize for Value<'_>

Source§

async fn serialize<'se>( &'se self, serializer: &'se mut dyn DynSerializer, ) -> Result<(), MerdeError<'static>>

Source§

impl<'s, 'instantiated_lifetime> WithLifetime<'instantiated_lifetime> for Value<'s>

Source§

type Lifetimed = Value<'instantiated_lifetime>

Source§

impl<'s> Eq for Value<'s>

Source§

impl<'s> StructuralPartialEq for Value<'s>

Auto Trait Implementations§

§

impl<'s> Freeze for Value<'s>

§

impl<'s> RefUnwindSafe for Value<'s>

§

impl<'s> Send for Value<'s>

§

impl<'s> Sync for Value<'s>

§

impl<'s> Unpin for Value<'s>

§

impl<'s> UnwindSafe for Value<'s>

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§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynDeserialize for T

Source§

fn dyn_deserialize<'de>( de: &'de mut dyn DynDeserializer<'de>, ) -> Result<Box<T>, MerdeError<'static>>

Source§

impl<S> DynSerialize for S
where S: Serialize,

Source§

fn dyn_serialize<'fut>( &'fut self, serializer: &'fut mut dyn DynSerializer, ) -> Pin<Box<dyn Future<Output = Result<(), MerdeError<'static>>> + 'fut>>

Dynamic dispatch version of Serialize::serialize.
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,

Source§

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

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.