具有字节字段的 Protobuf 结构
Protobuf structure with bytes field
有一个protobuf结构
message A {
bytes B = 1;
}
message B {
int32 c = 1;
int64 d = 2;
string x = 3;
}
如果我们将相同编码的原型缓冲区的字节放在 A.B 字段中
并解码或编码
pseudocode:
newA = &A{}
newB = &B{x:"123",c:1,d:3}
bytes_of_B = marshall(type(B), newB)
newA.B = bytes_of_B
bytes_of_A = marshall(type(A), newA)
pseudocode:
newA = unmarshall(bytes_of_A, type(A))
newB = unmarshall(newA.B, type(B))
这有多真实,这可能会带来什么后果
在 wire/payload 级别,此场景与
100% 相同
message A {
B B = 1;
}
所以:没有这样的后果,但告诉 A 期待 B 可能更方便。
有一个protobuf结构
message A {
bytes B = 1;
}
message B {
int32 c = 1;
int64 d = 2;
string x = 3;
}
如果我们将相同编码的原型缓冲区的字节放在 A.B 字段中 并解码或编码
pseudocode:
newA = &A{}
newB = &B{x:"123",c:1,d:3}
bytes_of_B = marshall(type(B), newB)
newA.B = bytes_of_B
bytes_of_A = marshall(type(A), newA)
pseudocode:
newA = unmarshall(bytes_of_A, type(A))
newB = unmarshall(newA.B, type(B))
这有多真实,这可能会带来什么后果
在 wire/payload 级别,此场景与
100% 相同message A {
B B = 1;
}
所以:没有这样的后果,但告诉 A 期待 B 可能更方便。