Enum tycho::Element[][src]

pub enum Element {
    Unit,
    Value(Value),
    Option(Option<Box<Element>>),
    Variant(StringBox<Element>),
    Struct(HashMap<String, Element>),
    List(Vec<Element>),
    Array(ValueIdentVec<Value>),
    Map(ValueIdentHashMap<Value, Element>),
    Compression(Box<Element>),
}

A element tag, used to build tycho data structures.

Elements represent zero, one or multiple pieces of data. They are non-primitive non-terminating and have the ability to contain typed and untyped values or elements.

Variants

Unit

Unit

A element representing no data.

Units are used when serializing from the following types:

  • Unit Struct (struct Foo;)
  • Unit Variant (enum Foo { Bar, Baz })
  • Unit (())
Value(Value)

Value

A element representing a primitive value.

A value element contains a Value object as its payload. Data structures that only contain a value with be prefixed with the ValueIdent.

A value can represent any of the following types:

  • bool
  • &str,
  • String
  • char
  • number - u8 u16 u32 u64 u128 i8 i16 i32 i64 i128 f32 f64
  • bytes - Vec<u8>
Option(Option<Box<Element>>)

Option

An element representing a Some or None value.

This element maps directly to Rust Option<T> type, and can have a payload of an element when some.

Variant(StringBox<Element>)

Variant

An element representing a named variable type.

This element represents a rust enum.

Unit Variants

e.g. enum Example { Foo, Bar, Baz }

A unit variant is a enum with no data.

Within tycho, the value Example::Foo would be represented as Variant("Foo", Unit)

Value Variants

e.g. enum Example { Foo(String), Bar(bool), Baz(u8) }

A ‘new type’ enum containing a single piece of data.

Within tycho, the value Example::Bar(false) would be represented as Variant("Bar", Value(Bool(0)))

Tuple Variants

e.g. enum Example { Foo(u8, bool), Bar(u16, bool), Baz(u32, bool) }

A ‘tuple’ enum containing a multiple unnamed pieces of data.

Within tycho, the value Example::Baz(10, true) would be represented as: Variant("Baz, List([Value(Unsigned32(10)), Value(Bool(1)]))

Struct Variants

e.g. enum Example { Foo { bar: char } }

A ‘tuple’ enum containing a multiple unnamed pieces of data.

Within tycho, the value Example::Foo { bar: 'P'} would be represented as: Variant("Baz, Struct({"bar": Value(Char('P'))))

Struct

An element representing an untyped string key - element paring.

Directly maps to rusts struct object within the serialisation process.

List(Vec<Element>)

List

An element representing an untyped collection of elements.

Directly maps to any tuple or heterogeneous array.

Array(ValueIdentVec<Value>)

Array

An element representing a strictly typed collection of values.

Unlike lists, arrays can only store terminating values and homogeneous.

Map

An element representing a strictly typed key - to untyped element pair.

They key of a map can be any terminating value, and is strictly typed. The value of a map can be any element and is homogeneous.

Compression(Box<Element>)

Compression Marker

Contains an element that will be g-zip compressed.

Trait Implementations

impl Clone for Element[src]

impl CompressElement for Element[src]

impl Debug for Element[src]

impl DecompressElement for Element[src]

impl Display for Element[src]

impl From<&'_ [u8]> for Element[src]

impl From<&'_ str> for Element[src]

impl<T: ValueType> From<Array<T>> for Element[src]

impl From<List> for Element[src]

impl<K: ValueType + Hash + Eq> From<Map<K>> for Element[src]

impl From<String> for Element[src]

impl From<Struct> for Element[src]

impl From<Uuid> for Element[src]

impl From<Value> for Element[src]

impl From<Vec<u8, Global>> for Element[src]

impl From<bool> for Element[src]

impl From<char> for Element[src]

impl From<f32> for Element[src]

impl From<f64> for Element[src]

impl From<i128> for Element[src]

impl From<i16> for Element[src]

impl From<i32> for Element[src]

impl From<i64> for Element[src]

impl From<i8> for Element[src]

impl From<u128> for Element[src]

impl From<u16> for Element[src]

impl From<u32> for Element[src]

impl From<u64> for Element[src]

impl From<u8> for Element[src]

impl Ident for Element[src]

type IdentType = ElementIdent

Respective ident type

impl PartialEq<Element> for Element[src]

impl StructuralPartialEq for Element[src]

impl TryFrom<Element> for Vec<u8>[src]

type Error = ()

The type returned in the event of a conversion error.

impl<K: ValueType + TryFrom<Value>> TryFrom<Element> for Array<K>[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<Element> for List[src]

type Error = ()

The type returned in the event of a conversion error.

impl<K: ValueType + Hash + Eq + TryFrom<Value>> TryFrom<Element> for Map<K>[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<Element> for Struct[src]

type Error = ()

The type returned in the event of a conversion error.

Auto Trait Implementations

impl RefUnwindSafe for Element

impl Send for Element

impl Sync for Element

impl Unpin for Element

impl UnwindSafe for Element

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> From<T> for T[src]

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,