The key-value store baseline example's implementation was a good starting point, but one major drawback is that data is stored as raw bytes. FIDL is a richly typed language. Forcing data that is for instance a UTF-8 string to be stored as an untyped byte array erases this valuable type information for readers of the *.fidl file, as well as for programmers using bindings generated from it.

The main goal of this change is to replace the baseline case‘s vector<byte> typed value member with a union that stores many possible types. In fact, as of this change a good survey of FIDL’s value types is on offer:

  • All of FIDL‘s builtin scalar types are used as variants in the Value union: bool, uint8, uint16, uint32, uint64, int8, int16, int32, int64, float32, and float64 (also known as FIDL’s primitive types), as well as string.
  • This union also features uses of FIDL's builtin array<T, N> and vector<T> type templates.
  • All of FIDL's type layouts, namely bits, enum, table, union, and struct, are utilized in this example at least once.

The request and response payloads used for WriteItem have also been changed from structs to a named table and an inlined flexible union, respectively. In fact, any of these three layouts may be used a request/response payload. The latter two, known as table payloads and *union payloads, respectively, are preferred in all but the most message size sensitive cases. This is because they are much easier to extend in the future in a binary compatible way.

Client and server implementations can then be written in any supported language: