Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to create a type alias in protobuf (proto2)?

Is it possible to create aliases of protobuf's scalar types?

For example, I'd like to use Sequence in lieu of string, even though they would be binary equivalent.

My immediate goal is to make documentation (generated with protoc-gen-doc) more readily understandable.

Ideally, this type would be represented in languages that support type checking, but that's not necessary.

like image 911
Reece Avatar asked Oct 27 '16 22:10

Reece


1 Answers

Well this will be a bit dull answer but:

No, I'm not aware of such feature existing or having been planned.

You can sort of emulate it by making submessages that contain only a single field, but that will alter the binary representation.

You're not the first asking this though:

  • Re: [protobuf] does protoc allow you to typedef a scalar ?
  • Is it possible to define an alias for type (enum or message) in google protobuf?
like image 69
jpa Avatar answered Sep 19 '22 15:09

jpa