Enum tycho::Element [−][src]
pub enum Element { Unit, Value(Value), Option(Option<Box<Element>>), Variant(String, Box<Element>), Struct(HashMap<String, Element>), List(Vec<Element>), Array(ValueIdent, Vec<Value>), Map(ValueIdent, HashMap<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
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 CompressElement for Element
[src]
impl CompressElement for Element
[src]impl DecompressElement 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(self) -> TychoResult<Self>
[src]Mark an element for decompression by extracting it from a compression element.
fn decompress_lossy(self) -> Self
[src]
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]
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 Ident for Element
[src]
impl Ident for Element
[src]type IdentType = ElementIdent
type IdentType = ElementIdent
Respective ident type
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> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
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]
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<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,