Here's the hsdt data format definition I'll begin implementing now. CC @Dominic
Quick summary
The format is obtained from the current, json-based one, by adding the following values:
- signed and unsigned integers (8, 16, 32, 64 bit)
- two float types (32 and 64 bit), supporting negative zero, both infinities, and a single
NaN
value - byte strings
- multifeeds (i.e.
@foo.ed25519
) - multihashes (i.e.
&bar.sha256
) - sets
- maps with arbitrary keys
Actual Spec
Abstract Data Model
The hsdt data model is based upon cbor. Some features were omitted to ensure canonicity, others were added for ssb-specific use cases.
Null
null
is an hsdt value that carries no information.
Booleans
true
and false
are hsdt values, called booleans.
Integers
Hsdt allows signed and unsigned fixed-width integers of the sizes 8, 16, 32 and 64 bytes. They are referred to as i8
, i16
, i32
and i64
(signed) and u8
, u16
, u32
and u64
(unsigned).
Floating Point Numbers
Hsdt allows the 32 bit and 64 bit floating point numbers from the IEEE 754 standard. They are referred to as f32
and f64
.
The only difference to IEEE 754: There is just a single value to represent NaN
per float type, not multiple ones.
Multifeeds
A multifeed is an hsdt value.
Multihash
A multihash is an hsdt value.
Byte Strings
An ordered sequence of bytes of length between 0
and 2^64 - 1
(inclusive) is an hsdt value, called a byte string. Such a byte string may include null bytes.
UTF-8 Strings
An ordered sequence of bytes which form valid utf8 of length between 0
and 2^64 - 1
(inclusive) is an hsdt value, called a utf-8 string. Such a utf-8 string may include null bytes.
Arrays
Let n
be a natural number less than 2^64
, and let v_0, ..., v_n
be hsdt values.
The ordered sequence [v_0, ..., v_n]
is an hsdt value, called an array.
Arrays
Let n
be a natural number less than 2^64
, and let v_0, ..., v_n
be hsdt values.
The (unordered) set #{v_0, ..., v_n}
is an hsdt value, called a set.
Maps
Let n
be a natural number less than 2^64
, let k_0, ..., k_n
be pairwise distinct hsdt values, and let v_0, ..., v_n
be arbitrary hsdt values.
The (unordered) set of pairs (k_i, v_i)
for all 0 <= i <= n
is a legacy value, called a map. The pairs are called entries, the first entries of the pairs are called keys, and the second entries of the pairs are called values.