spa_pod_parser wrapper
This adds a new wrapper type libspa::pod::parser::Parser around spa_pod_parser, which offers low-level bindings that may require unsafe and/or working with C types, but is still more rusty than working with the raw parser.
For creating a parser from a byte slice, and for parsing most "easy" pod types that can be parsed with a simple "get_*" call, no unsafe is neccessary.
When parsing structs, objects, etc., and using other functions that access/modify the state of the parser, unsafe is neccessary because the caller has to work with stack-allocated spa_pod_frame
s that the parser uses to keep track of the state, and those frames must be kept alive and unmoved until pop
ing them in the right order.
This new wrapper could be used in our serde-like PodDeserializer in the future to get rid of the custom and buggy nom implementation (and the nom dependency).
Also, I will add similar bindings for spa_pod_builder in later MR.
Unresolved:
-
We might requireNevermind, this would only work with pointer types. You can still move aPin
around provided frames to help callers make sure they don't move. This doesn't make the API fully safe because they could still be dropped early, but would help make it less dangerous. Would this create other problems somehow?Pin<T>
to another location and theT
moves with it. -
Should we make wrapper types around spa_pod_parser_state and spa_pod_frame?Maybe in a future MR. -
I left out a couple functions that I wasn't 100% sure about what they were doing, we might add those too.Done