OptionalSchema
A schema for values that may be absent, wrapping the schema for the value itself.
You rarely build one yourself. A nullable property gets one automatically, so class Target(val pose: Pose?) encodes pose as an optional POSE. Nullable type arguments work too, as in Map<String, Double?> and List<String?>.
Binary format
The schema:
[4 bytes: tag] [inner schema blob]An encoded value:
[1 byte: 0x00 absent]
[1 byte: 0x01 present] [value encoded by the inner schema]An absent value costs one byte. A present value costs one byte more than it would unwrapped.
Decoder compatibility
This schema uses tag 9, added after MAP. Log entries have no length prefix, so a reader that doesn't know the tag cannot skip the value. It stops at the first channel that uses one. Non-null fields encode as before.
Parameters
the value type when present
schema used to encode the value when it is present
Properties
Functions
Writes the given object into the buffer.
Writes the whole schema definition, starting with the tag, into the buffer.
Returns the number of bytes encodeObject writes for the given object.