簡體   English   中英

帶有字節字段的 Protobuf 結構

[英]Protobuf structure with bytes field

有一個protobuf結構

message A {
  bytes B = 1;
}

message B {
   int32 c = 1;
   int64 d = 2;
   string x = 3;
}

如果我們將相同編碼的 proto-buffer 的字節放在 AB 字段中並解碼或編碼

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))

這是多么真實,這可能會產生什么后果

在線路/有效負載級別,此場景 100% 與

message A {
  B B = 1;
}

所以:沒有這樣的后果,但告訴 A 期待 B 可能更方便。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM