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:

Share:
13,730
Reece
Author by

Reece

Updated on June 08, 2022

Comments

  • Reece
    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 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.

  • sudo
    sudo about 6 years
    Have they explained why not? Coming from ASN.1, this was the first feature I tried using. Would make things much cleaner.