[][src]Enum serde_object::Object

pub enum Object<'a> {
    Bool(bool),
    I8(i8),
    I16(i16),
    I32(i32),
    I64(i64),
    I128(i128),
    U8(u8),
    U16(u16),
    U32(u32),
    U64(u64),
    U128(u128),
    F32(f32),
    F64(f64),
    Char(char),
    String(Cow<'a, str>),
    ByteArray(Cow<'a, [u8]>),
    Option(Option<Box<Object<'a>>>),
    Unit,
    UnitStruct {
        name: Cow<'a, str>,
    },
    UnitVariant {
        name: Cow<'a, str>,
        variant: Box<Object<'a>>,
    },
    NewtypeStruct {
        name: Cow<'a, str>,
        value: Box<Object<'a>>,
    },
    NewtypeVariant {
        name: Cow<'a, str>,
        variant: Box<Object<'a>>,
        value: Box<Object<'a>>,
    },
    Seq(Vec<Object<'a>>),
    Tuple(Vec<Object<'a>>),
    TupleStruct {
        name: Cow<'a, str>,
        fields: Vec<Object<'a>>,
    },
    TupleVariant {
        name: Cow<'a, str>,
        variant: Box<Object<'a>>,
        fields: Box<Object<'a>>,
    },
    Map(Vec<(Object<'a>, Object<'a>)>),
    Struct {
        name: Cow<'a, str>,
        fields: Vec<(Cow<'a, str>, Option<Object<'a>>)>,
    },
    StructVariant {
        name: Cow<'a, str>,
        variant: Box<Object<'a>>,
        fields: Box<Object<'a>>,
    },
    DualVariantKey {
        index: u32,
        name: Cow<'a, str>,
    },
    FieldMap(Vec<(Object<'a>, Option<Object<'a>>)>),
}

Represents a Serde data model value, losslessly.
See https://serde.rs/data-model.html for more information.

Limitations

  • There is no way for Deserializers to hint what kind of enum variant they have available, so an assistant must be provided to support deserialising them at all.
    (Libraries can provide plug-in support here, which makes it possible to deserialize enum variants without specifying an assistant consumer-side.)

Leaks

Some memory is leaked when:

  • a UnitStruct is serialized (for its name).
  • a UnitVariant is serialized (for its name and variant).
  • a NewtypeStruct is serialized (for its name).
  • a NewtypeVariant is serialized (for its name and variant).
  • a TupleStruct is serialized (for its name).
  • a TupleVariant is serialized (for its name and variant).
  • a Struct is serialized (for its name and each of its field keys).
  • a StructVariant is deserialized (for its field keys).

TODO: Organise storage for these and add a way to clear it.

Variants

Bool(bool)
I8(i8)
I16(i16)
I32(i32)
I64(i64)
I128(i128)
U8(u8)
U16(u16)
U32(u32)
U64(u64)
U128(u128)
F32(f32)
F64(f64)
Char(char)
String(Cow<'a, str>)
ByteArray(Cow<'a, [u8]>)
Option(Option<Box<Object<'a>>>)
Unit
UnitStruct

Fields of UnitStruct

name: Cow<'a, str>
UnitVariant

Fields of UnitVariant

name: Cow<'a, str>variant: Box<Object<'a>>
NewtypeStruct

Fields of NewtypeStruct

name: Cow<'a, str>value: Box<Object<'a>>
NewtypeVariant

Fields of NewtypeVariant

name: Cow<'a, str>variant: Box<Object<'a>>value: Box<Object<'a>>
Seq(Vec<Object<'a>>)
Tuple(Vec<Object<'a>>)
TupleStruct

Fields of TupleStruct

name: Cow<'a, str>fields: Vec<Object<'a>>
TupleVariant

Fields of TupleVariant

name: Cow<'a, str>variant: Box<Object<'a>>fields: Box<Object<'a>>
Map(Vec<(Object<'a>, Object<'a>)>)

This variant does not care whether keys are duplicated.
Formats might mind it.

Struct

This variant may store duplicate fields. Formats may have a problem with it.

Fields of Struct

name: Cow<'a, str>fields: Vec<(Cow<'a, str>, Option<Object<'a>>)>
StructVariant

This variant may store duplicate fields. Formats may have a problem with it.

Fields of StructVariant

name: Cow<'a, str>variant: Box<Object<'a>>fields: Box<Object<'a>>
DualVariantKey

Created by [Serializer].
Serialized as string or u32 depending on the target ser::Serializer::is_human_readable().

Fields of DualVariantKey

index: u32name: Cow<'a, str>
FieldMap(Vec<(Object<'a>, Option<Object<'a>>)>)

Created by [Serializer] when serializing struct variants.
Like [Map], but fields may be skipped.

Implementations

impl<'a> Object<'a>[src]

pub fn into_owned(self) -> Object<'static>[src]

Trait Implementations

impl<'a> Debug for Object<'a>[src]

impl<'de> Deserialize<'de> for Object<'de>[src]

impl<'de> Deserializer<'de> for Object<'de>[src]

type Error = Error

The error type that can be returned if some error occurs during deserialization. Read more

impl<'de> IntoDeserializer<'de, Error> for Object<'de>[src]

type Deserializer = Self

The type of the deserializer being converted into.

impl<'a> Serialize for Object<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for Object<'a>

impl<'a> Send for Object<'a>

impl<'a> Sync for Object<'a>

impl<'a> Unpin for Object<'a>

impl<'a> UnwindSafe for Object<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T[src]

impl<T> FmtForward for T[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pipe for T[src]

impl<T> PipeAsRef for T[src]

impl<T> PipeBorrow for T[src]

impl<T> PipeDeref for T[src]

impl<T> PipeRef for T[src]

impl<T> Tap for T[src]

impl<T, U> TapAsRef<U> for T where
    U: ?Sized
[src]

impl<T, U> TapBorrow<U> for T where
    U: ?Sized
[src]

impl<T> TapDeref for T[src]

impl<T> TryConv for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.