lua-protobuf icon indicating copy to clipboard operation
lua-protobuf copied to clipboard

pb.hook cannot handle native types

Open git-torrent opened this issue 3 years ago • 2 comments

I am trying to hook bytes type to encode it into base64.

While I can hook other types, hooking native types gives me unknown type error.

I tried to recursively traverse the luatable proto representation and fix all the fields of type bytes ( by using pb.field() ), but this is tedious. Moreover, pb.hook() seems to be made exactly for this purpose.

Thanks

git-torrent avatar Sep 24 '21 16:09 git-torrent

Sorry for the missing of this feature, but it seems difficult for current implementation. Pull requests are welcome, and I will look into this to find out how to make it up 😑

starwing avatar Sep 25 '21 03:09 starwing

Too bad, I cannot fix this on my own (it requires lot of C-coding). To give some points: having hooks for any type would allow to implement proper JSON mapping as specified in https://developers.google.com/protocol-buffers/docs/proto3#json

Thank you

git-torrent avatar Sep 27 '21 22:09 git-torrent