Is there a way to create a type alias in protobuf (proto2)?
13,730
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?
Author by
Reece
Updated on June 08, 2022Comments
-
Reece about 2 years
Is it possible to create aliases of protobuf's scalar types?
For example, I'd like to use
Sequence
in lieu ofstring
, 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.
-
sudo about 6 yearsHave they explained why not? Coming from ASN.1, this was the first feature I tried using. Would make things much cleaner.