Enum tycho::Element [−][src]
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
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
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
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
An element representing an untyped collection of elements.
Directly maps to any tuple or heterogeneous array.
Array(ValueIdent, Vec<Value>)
Array
An element representing a strictly typed collection of values.
Unlike lists, arrays can only store terminating values and homogeneous.
Map(ValueIdent, HashMap<Value, Element>)
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 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]
fn _impl_decompress(self) -> Result<Self, (Self, TychoError)>
[src]
fn decompress(self) -> TychoResult<Self>
[src]
fn decompress_lossy(self) -> Self
[src]
fn decompress_opt(self) -> Option<Self>
[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]
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.
fn try_from(value: Element) -> Result<Self, Self::Error>
[src]
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]
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]
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]
impl TryFrom<Element> for Struct
[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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
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]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
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]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,