mbarbon / google-protobuf-dynamic

Fast and complete Perl protobuf implementation using uPB and Google .proto parser
35 stars 18 forks source link

Way to resolve protobuf message names to perl classes #39

Open scop opened 4 years ago

scop commented 4 years ago

Would be nice to have a way to resolve protobuf message names to the perl classes they are mapped to at runtime. So if I have a protobuf bytes blob and I know the protobuf message name for it, I could feed it to the appropriate perl class for decoding. For example $dynamic->resolve_message($protobuf_name) would return the perl class mapped to it.

Use case: I'm toying around implementing twirp support for perl, and basically mimicking what they do for their python support. Python protobuf stuff has a symbol db that can be used to look up things like this. For encoding there's no need for that as the given perl object can just be told to ->encode itself, but for decoding I'd need to have a class to feed the bytes to.