ESExpr
ESExpr is a serialization format that consists of exprssions of the following forms.
- A Constructor with a name and positional and keyword arguments.
- Booleans
- Integers
- Strings
- Binary Data
- Float32/64
- Null
Constructor and keyword names are stored in a string table to prevent duplication. The string table can be stored internally or externally. Each of these types has its own tag associated with it. Constructor tags include the constructor name.
Derivation
The ESExprCodec trait can be derived.
By default, the struct, enum case, and field names are converted to kebab-case.
In the above example, MyStruct has constructor my-struct and MyEnum has constructors a and b.
This can be customized using the constructor attribute.
In some cases, the encoding overhead of a constructor is undesireable for enum cases.
In such cases, inline_value can be used to encode a case directly.
Only a single field is allowed.
It is the responsibility of the user to ensure that the tags do not overlap with any other cases.
For simpler cases, string values can be used as an enum by adding simple_enum.
Each constructor name is encoded as a string value.
Fields may not be specified for any cases.
By default, fields specify positional arguments.
To define keyword arguments, use keyword.
Keyword arguments can be omitted if required is set to false.
Additionally, default values can be set using default_value.
To handle multiple arguments, vararg and dict can be used for positional and keyword arguments, respectively.