bigeasy / packet

Incremental binary parsers and serializers for Node.js.
http://bigeasy.github.io/packet
MIT License
186 stars 25 forks source link

Implement unvivified literals. #585

Closed bigeasy closed 4 years ago

bigeasy commented 4 years ago

Literals currently wrap a field definition of some kind, so that to define a literal you must specify it as occurring before or after some field. In MQTT headers I've encountered an 8-bit packed integer header with four bits for the type followed by 4 bits for flags which, depending on the type, may be a literal. That is, the flags may all be always zero, or the like. In this case there is nothing to wrap. Can't wrap the type with a literal because we need the type to determine if the flags are literal. Need instead to have some sort of literal specified with a name in the structure but never actually materialized.