amazon-ion / ion-rust

Rust implementation of Amazon Ion
Apache License 2.0
146 stars 34 forks source link

Derive `opcode_length` instead of setting it explicitly #805

Open zslayton opened 1 month ago

zslayton commented 1 month ago
          Can this be derived (i.e. `fn is_tagless() -> bool`) rather than storing the opcode length in a field? Tagless encodings _must_ have `value_body_length + length_length == total_length`, and anything else _must_ have an opcode, so `value_body_length + length_length < total_length` is always true for anything that is not a tagless encoded argument. Right?

_Originally posted by @popematt in https://github.com/amazon-ion/ion-rust/pull/801#discussion_r1712903906_

zslayton commented 1 month ago

Also look into addressing this comment:

Perhaps Header should actually be an enum so that it could have a NoHeader variant in addition to whatever other implementations you have going on?