<<Sz:8,Payload:Sz/binary-unit:8,Rest/binary>>
[0] https://www.erlang.org/doc/programming_examples/bit_syntax.h...
decode(<<16#01, Size:8, Payload:Size/binary-unit:8, Rest/binary>>) -> [{field1, Payload}|decode(Rest)]; decode(<<16#02, Flags:16, Rest/binary>>) when Flags =:= 1 -> [{field2, true}|decode(Rest)]; decode(<<16#02, Flags:16, Rest/binary>>) -> [{field2, false}|decode(Rest)].
[0] https://www.erlang.org/doc/programming_examples/bit_syntax.h...