ssz.cr
Simple Serialize (SSZ)
This package implements simple serialize algorithm specified in official Ethereum 2.0 spec.
Installation
-
Add the dependency to your
shard.yml:dependencies: ssz: github: light-side-software/ssz.cr -
Run
shards install
Usage
require "ssz"
class Person
include SSZ::Serializable
property name : String = ""
property age : UInt16 = 0_u16
def initialize(@name : String, @age : UInt16)
end
end
person = Person.new("John", 32)
encoded = person.ssz_encode
decoded = Person.ssz_decode(encoded)
Supported types
- Nil
- Bool
- Int8
- UInt8
- Int16
- UInt16
- Int32
- UInt32
- Int64
- UInt64
- Int128
- UInt128
- Float32
- Float64
- BigDecimal
- BigFloat
- BigInt
- BigRational
- Complex - serialize as pair of
Float64(real and imag) - Enum - supports underlying types
- Char - Unicode 4 bytes
- String - supports Unicode
- Union(T) - where
Tis supported type - Array(T) - where
Tis supported type - Deque(T) - where
Tis supported type - StaticArray(T) - where
Tis supported type - Slice(T) - where
Tis supported type - Set(T) - where
Tis supported type - Range(B, E) - where
BandEare supported types - Time - serialize as
Int64UTC timestamp - Time::Span - serialize as pair of
Int64(seconds) andInt32(nanoseconds) - URI - serialize as
String - UUID - serialize as
String - SemanticVersion - serialize as
String - SemanticVersion::Prerelease - serialize as
String - Class and Struct which includes
SSZ::Serializablesee example above
Contributing
- Fork it (https://github.com/light-side-software/ssz.cr/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Tamás Szekeres - creator and maintainer
Repository
ssz.cr
Owner
Statistic
- 0
- 0
- 0
- 0
- 0
- over 6 years ago
- June 20, 2019
License
MIT License
Links
Synced at
Tue, 28 Oct 2025 05:53:48 GMT
Languages