prost-reflect icon indicating copy to clipboard operation
prost-reflect copied to clipboard

Extend unknown fields API

Open andrewhickman opened this issue 1 year ago • 0 comments

#52 exposed a way to list unknown fields for a message. We should support more functionality like

  • Get unknown fields with a given number
  • Remove a specified unknown field
    • One challenge is how to specify the field, since we can have multiple unknown fields with a given number
  • Insert a new unknown field
    • What should happen if the given field number corresponds to a known field or extension? We could try to interpret the bytes of the unknown field as the actual field type, or simply return an error.

There is also currently no API to inspect the value of an unknown field. We could expose something like the UnknownFieldValue enum:

https://github.com/andrewhickman/prost-reflect/blob/15368a7c20b651ecd134d7810c21914202f47371/prost-reflect/src/dynamic/unknown.rs#L24-L37

However if prost ever supports unknown fields, it would be nice to simply re-use its types, so it may be worth staying conservative for now.

andrewhickman avatar Aug 29 '23 18:08 andrewhickman