Protocol buffers 在protobuf消息中定义嵌套的消息之一
我试图在protobuf消息中定义嵌套的消息之一。我们可以在protobuf消息中嵌套一条消息吗Protocol buffers 在protobuf消息中定义嵌套的消息之一,protocol-buffers,grpc,Protocol Buffers,Grpc,我试图在protobuf消息中定义嵌套的消息之一。我们可以在protobuf消息中嵌套一条消息吗 谢谢您可以使用包含消息的“oneof”来定义消息。这些消息还可能包含“其中之一” 例如,如果我有一个API来控制我的硬件,包括一个冷却器和注射泵,并且它们各自支持自己的操作,可能每个操作都有不同的参数,那么我的API允许对单个设备执行单个命令,并且只强制使用正确的参数: syntax="proto3"; message ChillerSetTemperature { i
谢谢您可以使用包含消息的“oneof”来定义消息。这些消息还可能包含“其中之一” 例如,如果我有一个API来控制我的硬件,包括一个冷却器和注射泵,并且它们各自支持自己的操作,可能每个操作都有不同的参数,那么我的API允许对单个设备执行单个命令,并且只强制使用正确的参数:
syntax="proto3";
message ChillerSetTemperature {
int32 temperature=1;
}
message ChillerGetTemperature {
bool noArg=1;
}
message Chiller {
oneof command {
ChillerSetTemperature Set = 1;
ChillerGetTemperature Get = 2;
}
}
message SyringePumpAspirate {
int32 volume = 1;
int32 speed = 2;
}
message SyringePumpDispense {
int32 volume = 1;
int32 speed = 2;
}
message SyringePumpSelectPort {
int32 position=1;
}
message Syringe {
oneof command {
SyringePumpAspirate Aspirate = 1;
SyringePumpDispense Dispense = 2;
SyringePumpSelectPort SelectPort = 3;
}
}
message Action {
oneof device {
Syringe syringe = 1;
Chiller chiller = 2;
}
}
你尝试这个的时候发生了什么?我也有同样的问题。我在其中的第一个嵌套字段上得到错误“缺少字段编号”。例子: