4 ms·
At which point I loose all the benefits of lazy decoding that the accessor methods can provide, so I could just decode directly into a sensible struct, except y
by mxey 2y ago
At which point I loose all the benefits of lazy decoding that the accessor methods can provide, so I could just decode directly into a sensible struct, except you can’t with Protobuf.
- mort96 2y agoAccessor methods aren't for lazy decoding but for more efficient memory layouts.
- aktau 2y agoBoth, actually. Without accessor methods, laziness couldn't be implemented.
- mxey 2y agoBut that will also not transfer over to the domain struct
- mort96 2y agoWell it depends. If your data model doesn't include "this bool is optional", you can just include the bool directly in the struct and get all the memory layout advantages, and then you decide in your protobuf -> domain type conversion code whether it's an error if that field is missing or if it just defaults to 'false'. You only need to make ways for a field to be optional (such as naming it a pointer where nil represents "missing") when that actually makes sense in your data model.