pub enum PrefabValue {
Show 29 variants Unit, 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(String), Bytes(Vec<u8, Global>), Option(Option<Box<Intermediate, Global>>), UnitStruct, UnitVariant(String), NewTypeStruct(Box<Intermediate, Global>), NewTypeVariant(StringBox<Intermediate, Global>), Seq(Vec<Intermediate, Global>), Tuple(Vec<Intermediate, Global>), TupleStruct(Vec<Intermediate, Global>), TupleVariant(StringVec<Intermediate, Global>), Map(Vec<(Intermediate, Intermediate), Global>), Struct(Vec<(String, Intermediate), Global>), StructVariant(StringVec<(String, Intermediate), Global>),
}
Expand description

Serde intermediate data representation.

Example

use std::time::SystemTime;
use serde::{Serialize, Deserialize};

#[derive(Debug, PartialEq, Serialize, Deserialize)]
enum Login {
    Email(String),
    SocialMedia{
        service: String,
        token: String,
        last_login: Option<SystemTime>,
    }
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
struct Person {
    // (first name, last name)
    name: (String, String),
    age: usize,
    login: Login,
}

let data = Person {
    name: ("John".to_owned(), "Smith".to_owned()),
    age: 40,
    login: Login::Email("john.smith@gmail.com".to_owned()),
};
let serialized = serde_intermediate::to_intermediate(&data).unwrap();
let deserialized = serde_intermediate::from_intermediate(&serialized).unwrap();
assert_eq!(data, deserialized);

Variants

Unit

Unit value: ().

Bool(bool)

Bool value: true.

I8(i8)

8-bit signed integer value: 42.

I16(i16)

16-bit signed integer value: 42.

I32(i32)

32-bit signed integer value: 42.

I64(i64)

64-bit signed integer value: 42.

I128(i128)

128-bit signed integer value: 42.

U8(u8)

8-bit unsigned integer value: 42.

U16(u16)

16-bit unsigned integer value: 42.

U32(u32)

32-bit unsigned integer value: 42.

U64(u64)

64-bit unsigned integer value: 42.

U128(u128)

128-bit unsigned integer value: 42.

F32(f32)

32-bit floating point value: 3.14.

F64(f64)

64-bit floating point value: 3.14.

Char(char)

Single character value: '@'.

String(String)

String value: "Hello World!".

Bytes(Vec<u8, Global>)

Bytes buffer.

Option(Option<Box<Intermediate, Global>>)

Tuple Fields

Option value: Some(42).

UnitStruct

Structure: struct Foo;.

UnitVariant(String)

Tuple Fields

0: String

Variant name.

Enum unit variant: enum Foo { Bar }.

NewTypeStruct(Box<Intermediate, Global>)

Newtype struct: struct Foo(bool);.

NewTypeVariant(StringBox<Intermediate, Global>)

Tuple Fields

0: String

Variant name.

1: Box<Intermediate, Global>

Value.

Enum newtype variant: enum Foo { Bar(bool) }.

Seq(Vec<Intermediate, Global>)

Tuple Fields

0: Vec<Intermediate, Global>

Items.

Sequence/list: Vec<usize>, [usize].

Tuple(Vec<Intermediate, Global>)

Tuple Fields

0: Vec<Intermediate, Global>

Fields.

Tuple: (bool, char).

TupleStruct(Vec<Intermediate, Global>)

Tuple Fields

0: Vec<Intermediate, Global>

Fields.

Tuple struct: struct Foo(bool, char).

TupleVariant(StringVec<Intermediate, Global>)

Tuple Fields

0: String

Variant name.

1: Vec<Intermediate, Global>

Fields.

Tuple variant: enum Foo { Bar(bool, char) }.

Map(Vec<(Intermediate, Intermediate), Global>)

Tuple Fields

0: Vec<(Intermediate, Intermediate), Global>

Entries: (key, value).

Map: HashMap<String, usize>.

Struct(Vec<(String, Intermediate), Global>)

Tuple Fields

0: Vec<(String, Intermediate), Global>

Fields: (name, value).

Struct: struct Foo { a: bool, b: char }.

StructVariant(StringVec<(String, Intermediate), Global>)

Tuple Fields

0: String

Variant name.

1: Vec<(String, Intermediate), Global>

Fields: (name, value).

Enum struct variant: enum Foo { Bar { a: bool, b: char } }.

Implementations

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Deserialize this value from the given Serde deserializer. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.