|
@@ -91,6 +91,27 @@ encoded as an empty map because it has no exported fields, while UUID
|
|
|
would be encoded as a string. However, with extension support, you can
|
|
would be encoded as a string. However, with extension support, you can
|
|
|
encode any of these however you like.
|
|
encode any of these however you like.
|
|
|
|
|
|
|
|
|
|
+## Custom Encoding and Decoding
|
|
|
|
|
+
|
|
|
|
|
+This package maintains symmetry in the encoding and decoding halfs.
|
|
|
|
|
+We determine how to encode or decode by walking this decision tree
|
|
|
|
|
+
|
|
|
|
|
+ - is type a codec.Selfer?
|
|
|
|
|
+ - is there an extension registered for the type?
|
|
|
|
|
+ - is format binary, and is type a encoding.BinaryMarshaler and BinaryUnmarshaler?
|
|
|
|
|
+ - is format specifically json, and is type a encoding/json.Marshaler and Unmarshaler?
|
|
|
|
|
+ - is format text-based, and type an encoding.TextMarshaler?
|
|
|
|
|
+ - else we use a pair of functions based on the "kind" of the type e.g. map, slice, int64, etc
|
|
|
|
|
+
|
|
|
|
|
+This symmetry is important to reduce chances of issues happening because the
|
|
|
|
|
+encoding and decoding sides are out of sync e.g. decoded via very specific
|
|
|
|
|
+encoding.TextUnmarshaler but encoded via kind-specific generalized mode.
|
|
|
|
|
+
|
|
|
|
|
+Consequently, if a type only defines one-half of the symetry
|
|
|
|
|
+(e.g. it implements UnmarshalJSON() but not MarshalJSON() ),
|
|
|
|
|
+then that type doesn't satisfy the check and we will continue walking down the
|
|
|
|
|
+decision tree.
|
|
|
|
|
+
|
|
|
## RPC
|
|
## RPC
|
|
|
|
|
|
|
|
RPC Client and Server Codecs are implemented, so the codecs can be used
|
|
RPC Client and Server Codecs are implemented, so the codecs can be used
|