This library provides data types and functions to interact with Antelope blockchains.
The basic types can be found in the [types] module, and the variant type used to represent
values handled by Antelope blockchains is [AntelopeValue].
There is a to-do list of items needing to be completed before a first release here: To-Do list, and a list of notes and resources here: Notes
You can also read an overview of the architecture and design decisions.
Feature flags
detailed-error: activate this to enable the [macro@with_location] macro. If not enabled, the [macro@with_location] macro will be a no-op.hardened: implement safeguards to check for execution time and recursion depth when validating ABIs. (NOT IMPLEMENTED YET!)float128: add support for a nativefloat128type. This currently needs a nightly Rust version asf128support is still experimental. If this is not active, theFloat128will still be available but as a[u8; 16]wrapper.
Antelope data model
![Antelope data model][datamodel]
Data used in the Antelope blockchains can be found in a variety of formats, namely:
- Rust native data types (structs defined in this library)
- JSON Value (
serde_json::Value) (also called variant in Antelope terminology) - JSON string representation
- binary data
The diagram above shows those types and the different ways to convert between them.
- most of the conversions are handled via the
serde::Serializeandserde::Deserializetraits. - to convert between a JSON value and a binary stream you need to use an instance
of the [
ABI] class which has been initialized with a data schema ([ABIDefinition]). - to convert between a Rust native value and a binary stream you need to use the
[
ABISerializable] trait, which you can automatically derive using theABISerializablederive macro.
Traits implemented for native types
Wherever possible, the following traits are implemented for the base types:
- [
Clone], and also [Copy] when the struct size isn't prohibitively big DebugandDisplayFromStr, allowing most types to be constructed from theirstrrepresentation via [str::parse()]- [
PartialEq], [Eq], [PartialOrd], [Ord], [Hash]
Warnings / pitfalls
- when defining your own types, make sure to use the [
Bytes] type instead ofVec<u8>otherwise the JSON serialization will not be correct. - when defining a variant type using a Rust enum, you need to use the [
SerializeEnum] derive macro instead ofserde::Serializeandserde::Deserialize. This is because the discriminant needs to be encoded in a specific way which cannot be achieved with theserde::Serializetrait.
Differences between this library and the Antelope C++ library
- hex numbers here are lowercase whereas C++ outputs hex data in upper case
- C++ outputs
i64andu64as double-quoted, this library doesn't