summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/transient-0.md17
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.