diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-07-13 21:22:26 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-07-13 21:22:26 +0100 |
| commit | 2c90667a91e8162a56d2052965c8a1ac3363c175 (patch) | |
| tree | d3be6007ff5508e0291655d24ba05e5b4286b41d /docs/transient-0.md | |
| parent | 5f8009a7ddf811aa907959d47dd3c9c5afd5d3db (diff) | |
Document transient-0 encoding
Diffstat (limited to 'docs/transient-0.md')
| -rw-r--r-- | docs/transient-0.md | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/docs/transient-0.md b/docs/transient-0.md index 42d956f..410bb62 100644 --- a/docs/transient-0.md +++ b/docs/transient-0.md @@ -15,4 +15,21 @@ transient-0 does not support: added to a struct, there is no guarantee that data encoded before the field was added can be decoded using the new data definition. +## Encoding +This describes the current encoding of transient-0. + +* `Bool`: a one-byte integer where true and false are represented by + 1 and 0 respectively. +* `Int32`: a four-byte little endian integer. +* `Int64`: an eight-byte little endian integer. +* `String`: the length of the UTF-8 encoding of the string written as per + `Int64`, followed by that UTF-8 encoding. +* `Option[T]`: if `none`, encoded as per `false`, otherwise encoded as per + `true` followed by the encoding of the value as per `T`. +* `List[T]`: the number of elements in the list encoded as per `Int64`, followed + by each of the elements in the list encoded as per `T`. +* A struct is encoded by encoding each of its fields in definition order. +* An enum is encoded by the index of the variant as per `Int32`. +* A sum is encoded by the index of the variant as per `Int32` followed by the + encoding as per the type of the variant. |
