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]

fn clone(&self) -> Element[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl CompressElement for Element[src]

fn compress(self) -> Self[src]

Mark an element for compression by placing it within a compression element.

impl Debug for Element[src]

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

Formats the value using the given formatter. Read more

impl DecompressElement for Element[src]

fn _impl_decompress(self) -> Result<Self, (Self, TychoError)>[src]

fn decompress(self) -> TychoResult<Self>[src]

Mark an element for decompression by extracting it from a compression element.

fn decompress_lossy(self) -> Self[src]

Mark an element for decompression by extracting it from a compression element. If the function fails, the element will be returned untouched. Read more

fn decompress_opt(self) -> Option<Self>[src]

Mark an element for decompression by extracting it from a compression element. If the function fails, None is returned Read more

impl Display for Element[src]

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

Formats the value using the given formatter. Read more

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

fn from(value: &[u8]) -> Self[src]

Performs the conversion.

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

fn from(value: &str) -> Self[src]

Performs the conversion.

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

fn from(a: Array<T>) -> Self[src]

Performs the conversion.

impl From<List> for Element[src]

fn from(l: List) -> Self[src]

Performs the conversion.

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

fn from(m: Map<K>) -> Self[src]

Performs the conversion.

impl From<String> for Element[src]

fn from(value: String) -> Self[src]

Performs the conversion.

impl From<Struct> for Element[src]

fn from(s: Struct) -> Self[src]

Performs the conversion.

impl From<Uuid> for Element[src]

fn from(value: Uuid) -> Self[src]

Performs the conversion.

impl From<Value> for Element[src]

fn from(v: Value) -> Self[src]

Performs the conversion.

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

fn from(value: Vec<u8>) -> Self[src]

Performs the conversion.

impl From<bool> for Element[src]

fn from(value: bool) -> Self[src]

Performs the conversion.

impl From<char> for Element[src]

fn from(value: char) -> Self[src]

Performs the conversion.

impl From<f32> for Element[src]

fn from(value: f32) -> Self[src]

Performs the conversion.

impl From<f64> for Element[src]

fn from(value: f64) -> Self[src]

Performs the conversion.

impl From<i128> for Element[src]

fn from(value: i128) -> Self[src]

Performs the conversion.

impl From<i16> for Element[src]

fn from(value: i16) -> Self[src]

Performs the conversion.

impl From<i32> for Element[src]

fn from(value: i32) -> Self[src]

Performs the conversion.

impl From<i64> for Element[src]

fn from(value: i64) -> Self[src]

Performs the conversion.

impl From<i8> for Element[src]

fn from(value: i8) -> Self[src]

Performs the conversion.

impl From<u128> for Element[src]

fn from(value: u128) -> Self[src]

Performs the conversion.

impl From<u16> for Element[src]

fn from(value: u16) -> Self[src]

Performs the conversion.

impl From<u32> for Element[src]

fn from(value: u32) -> Self[src]

Performs the conversion.

impl From<u64> for Element[src]

fn from(value: u64) -> Self[src]

Performs the conversion.

impl From<u8> for Element[src]

fn from(value: u8) -> Self[src]

Performs the conversion.

impl Ident for Element[src]

type IdentType = ElementIdent

Respective ident type

fn ident(&self) -> Self::IdentType[src]

Get the respective ident for the element.

impl PartialEq<Element> for Element[src]

fn eq(&self, other: &Element) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Element) -> bool[src]

This method tests for !=.

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

type Error = ()

The type returned in the event of a conversion error.

fn try_from(value: Element) -> Result<Self, Self::Error>[src]

Performs the conversion.

impl TryFrom<Element> for Uuid[src]

type Error = ()

The type returned in the event of a conversion error.

fn try_from(value: Element) -> Result<Self, Self::Error>[src]

Performs the conversion.

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

type Error = ()

The type returned in the event of a conversion error.

fn try_from(value: Element) -> Result<Self, Self::Error>[src]

Performs the conversion.

impl TryFrom<Element> for List[src]

type Error = ()

The type returned in the event of a conversion error.

fn try_from(value: Element) -> Result<Self, Self::Error>[src]

Performs the conversion.

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.

fn try_from(value: Element) -> Result<Self, Self::Error>[src]

Performs the conversion.

impl TryFrom<Element> for Struct[src]

type Error = ()

The type returned in the event of a conversion error.

fn try_from(value: Element) -> Result<Self, Self::Error>[src]

Performs the conversion.

impl StructuralPartialEq for Element[src]

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]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T> ToString for T where
    T: Display + ?Sized
[src]

pub default fn to_string(&self) -> String[src]

Converts the given value to a String. Read more

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

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

pub fn vzip(self) -> V