Efficient and space-efficient serialization of Rust types.
This library provides structures to easily retrieve compile-time type
information at runtime and also to serialize this information in a
space-efficient form, aka
At the heart of its functionality is the
that acts as a cache for known types in order to efficiently deduplicate
types and ensure a space-efficient serialization.
Information about types is provided via the
This trait should be implemented for all types that are serializable.
tetsy-scale-info provides implementations for all commonly used Rust standard
types and a derive macro for implementing of custom types.
To bridge between compile-time type information and runtime the
MetaForm is used to easily retrieve all
information needed to uniquely identify types.
MetaForm and its associated
Registry can be transformed into the
space-efficient form by the
IntoPortable trait; it is
used internally by the
Registry in order to convert
the expanded types into their space-efficient form.
To differentiate two types sharing the same name, namespaces are used.
Commonly the namespace is equal to the one where the type has been defined
in. For Rust prelude types such as
Result the root namespace (empty namespace) is
To use this library simply use the
initially with your own data structures; make them generic over the
Form trait just as has been done in this crate with
TypeInfo in order to get a simple implementation of
IntoPortable. Use a single instance of the
Registry for compaction and provide this registry
instance upon serialization.
A usage example can be found in ink! here: https://github.com/paritytech/ink/blob/master/abi/src/specs.rs
Builders for defining metadata for variant types (enums), and composite types (structs). They are designed to allow only construction of valid definitions.
Provides form definitions.
Interning data structure and associated symbol definitions.
Takes a number of types and returns a vector that contains their respective
A field of a struct-like data type.
A metatype abstraction.
Represents the path of a type definition.
A read-only registry containing types in their portable form for serialization.
The registry for space-efficient storage of type identifiers and definitions.
An array type.
A composite type, consisting of either named (struct) or unnamed (tuple struct) fields
A type describing a
A type to refer to a sequence of elements of the same type.
A type to refer to tuple types.
A Enum type (consisting of variants).
A struct enum variant with either named (struct) or unnamed (tuple struct) fields.
An error that may be encountered upon constructing namespaces.
The possible types a SCALE encodable Rust value could have.
A primitive Rust type.
Convert the type definition into the portable form using a registry.
Implementors return their meta type information.
Returns the runtime bridge to the types compile-time type information.