有没有办法在protobuf(proto2)中创建类型别名? [英] Is there a way to create a type alias in protobuf (proto2)?

查看:397
本文介绍了有没有办法在protobuf(proto2)中创建类型别名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以创建protobuf标量类型的别名?

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

例如,我想使用 Sequence 代替 string ,即使它们是等效的。

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

我的近期目标是制作文档(使用protoc-gen-doc生成)更容易理解。

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.

推荐答案

这个答案会有些沉闷,但是:

Well this will be a bit dull answer but:

不,我

您可以通过仅包含单个字段的子消息来模拟它,但这会改变二进制

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:


  • < a href = https://groups.google.com/forum/#!msg/protobuf/uvcQc43-_r0/aVdi1uI6lI0J rel = nofollow noreferrer>回复:[protobuf]确实有协议低你要键入一个标量?


  • 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?

这篇关于有没有办法在protobuf(proto2)中创建类型别名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆