StaticValue

Type Alias StaticValue 

Source
pub type StaticValue = Value<'static>;
Expand description

A Value with static lifetime for borrowed data (strings, bytes).

See Static strings for more info.

Aliased Type§

pub enum StaticValue {
Show 30 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), Str(Cow<'static, str>), Bytes(Cow<'static, [u8]>), Unit, Some, None, UnitStruct(&'static str), UnitVariant { name: &'static str, variant_index: u32, variant: &'static str, }, NewtypeStruct(&'static str), NewtypeVariant { name: &'static str, variant_index: u32, variant: &'static str, }, Seq(Option<usize>), Tuple(usize), TupleStruct { name: &'static str, len: usize, }, TupleVariant { name: &'static str, variant_index: u32, variant: &'static str, len: usize, }, Map(Option<usize>), Struct { name: &'static str, len: usize, }, StructVariant { name: &'static str, variant_index: u32, variant: &'static str, len: usize, },
}

Variants§

§

Bool(bool)

bool value

§

I8(i8)

i8 value

§

I16(i16)

i16 value

§

I32(i32)

i32 value

§

I64(i64)

i64 value

§

I128(i128)

i128 value

§

U8(u8)

u8 value

§

U16(u16)

u16 value

§

U32(u32)

u32 value

§

U64(u64)

u64 value

§

U128(u128)

u128 value

§

F32(f32)

f32 value

§

F64(f64)

f64 value

§

Char(char)

char value

§

Str(Cow<'static, str>)

String value, borrowed or owned.

§

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

Bytes value, borrowed or owned.

Note that you need to use serde_bytes or do custom (de)serialization in order to get bytes value as a [u8] slice instead of a sequence.

§

Unit

Unit value, i.e. ().

§

Some

Metadata (marker) for a value of Option<T>::Some(...).

During serialization, the actual value contained in the Option is serialized in the follow up calls to the serializer. This metadata can thus be seen as a marker, telling that the actual value serialization will follow.

§

None

Metadata (marker) for a value of Option<T>::None.

§

UnitStruct(&'static str)

Metadata for a value of unit struct type (e.g. struct Unit).

Tuple Fields

§0: &'static str

Struct name, e.g. "Unit" in struct Unit.

§

UnitVariant

Metadata for a value of unit variant type (e.g. E::A in enum E { A, B }).

Fields

§name: &'static str

Enum name.

For example, this would be "E" in enum E { A, B }.

§variant_index: u32

Variant index in the enum.

For example, this would be 0 for E::A, 1 for E::B in enum E { A, B }.

Note that this is always a sequential index, not the numeric value assigned to the variant.

§variant: &'static str

Variant name.

For example, this would be "A" for E::A in enum E { A, B }.

§

NewtypeStruct(&'static str)

Metadata for a value of newtype struct (e.g. struct Millimeters(u8)).

Tuple Fields

§0: &'static str

Struct name, e.g. "Millimeters" in struct Millimeters(u8).

§

NewtypeVariant

Metadata for a value of unit variant type (e.g. E::N in enum E { N(u8) }).

Fields

§name: &'static str

Enum name.

For example, this would be "E" in enum E { N(u8) }.

§variant_index: u32

Variant index in the enum.

For example, this would be 0 for E::N in enum E { N(u8) }.

§variant: &'static str

Variant name.

For example, this would be "N" for E::N in enum E { N(u8) }.

§

Seq(Option<usize>)

Metadata for a value of sequence type (e.g. Vec<T> or HashSet<T>).

Tuple Fields

§0: Option<usize>

Length of the sequence, if known during (de)serialization.

§

Tuple(usize)

Metadata for a value of tuple type.

Tuple Fields

§0: usize

Tuple length.

Note that unlike Seq, the length is not optional and must be known during (de)serialization.

§

TupleStruct

Metadata for a value of tuple struct type (e.g. struct Rgb(u8, u8, u8)).

Fields

§name: &'static str

Struct name, e.g. "Rgb" in struct Rgb(u8, u8, u8).

§len: usize

Tuple length, e.g. 3 in struct Rgb(u8, u8, u8).

§

TupleVariant

Metadata for a value of tuple variant type (e.g. E::T in enum E { T(u8, u8) }).

Fields

§name: &'static str

Enum name.

For example, this would be "E" in enum E { T(u8, u8) }.

§variant_index: u32

Variant index in the enum.

For example, this would be 0 for E::T in enum E { T(u8, u8) }.

§variant: &'static str

Variant name.

For example, this would be "T" for E::T in enum E { T(u8, u8) }.

§len: usize

Tuple length, e.g. 2 for E::T in enum E { T(u8, u8) }.

§

Map(Option<usize>)

Metadata for a value of map type (e.g. BTreeMap<K, V>).

Tuple Fields

§0: Option<usize>

Number of map entries, if known during (de)serialization.

§

Struct

Metadata for a value of struct type (e.g. struct S { r: u8, g: u8, b: u8 }).

Fields

§name: &'static str

Struct name, e.g. "S" in struct S { r: u8, g: u8, b: u8 }.

§len: usize

Number of struct fields, e.g. 3 in struct S { r: u8, g: u8, b: u8 }.

Note that unlike Map, the number of fields must be known during (de)serialization.

Some (de)serializers do not distinguish between maps and structures, while some others do.

§

StructVariant

Metadata for a value of struct variant type (e.g. E::S in enum E { S { r: u8, g: u8, b: u8 } }).

Fields

§name: &'static str

Enum name.

For example, this would be "E" in enum E { S { r: u8, g: u8, b: u8 } }.

§variant_index: u32

Variant index in the enum.

For example, this would be 0 for E::S in enum E { S { r: u8, g: u8, b: u8 } }.

§variant: &'static str

Variant name.

For example, this would be "S" for E::S in enum E { S { r: u8, g: u8, b: u8 } }.

§len: usize

Number of struct fields, e.g. 3 for E::S in enum E { S { r: u8, g: u8, b: u8 } }.