Skip to main content

Module tl

Module tl 

Source
Expand description

The SML type-length encoding.

Every SML value starts with one or more TL bytes:

 bit   7     6 5 4     3 2 1 0
      more   type      length nibble

type is 000 octet string, 100 boolean, 101 integer, 110 unsigned, 111 list. When more is set, another TL byte follows whose low nibble extends the length (most significant nibble first) and whose type bits are zero.

For a list the length is the number of elements. For every other type it is the number of bytes including the TL bytes themselves, which is why 0x01 is an empty octet string, the marker SML uses for an absent optional field. 0x00 is the end-of-message marker, not a value.

Structs§

Reader
A cursor over SML bytes. Never allocates and never panics.
Tl
A decoded type-length field.
Writer
A cursor that writes SML values into a caller-provided buffer.

Enums§

Kind
The type of an SML value.

Constants§

ABSENT
The marker for an absent optional field (an empty octet string).
END_OF_MESSAGE
The end-of-message marker.
MAX_DEPTH
How deep Reader::skip follows nested lists before it gives up.