From 2c90667a91e8162a56d2052965c8a1ac3363c175 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Mon, 13 Jul 2026 21:22:26 +0100 Subject: Document transient-0 encoding --- docs/transient-0.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'docs') 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. -- cgit v1.2.3