Add support for protobuf-serialization 0.2.0.

Does not break support for 0.1.0 thanks to a provided shim.
This commit is contained in:
Luke Parker 2020-07-23 20:23:29 -05:00
parent 438883dce3
commit 1539076cd8
1 changed files with 6 additions and 2 deletions

View File

@ -4,14 +4,18 @@ import stew/endians2
import nimcrypto import nimcrypto
import protobuf_serialization import protobuf_serialization
#Shim until https://github.com/status-im/nim-protobuf-serialization/pull/5 is merged.
when not defined(protobuf3):
template protobuf3() {.pragma.}
type type
Message* = ref object Message* {.protobuf3.} = ref object
group* {.fieldNumber: 1.}: seq[byte] #Assigned into a group by developer, not protocol. group* {.fieldNumber: 1.}: seq[byte] #Assigned into a group by developer, not protocol.
time* {.pint, fieldNumber: 2.}: int64 time* {.pint, fieldNumber: 2.}: int64
body* {.fieldNumber: 3.}: seq[byte] body* {.fieldNumber: 3.}: seq[byte]
id {.dontSerialize.}: seq[byte] id {.dontSerialize.}: seq[byte]
Payload* = object Payload* {.protobuf3.} = object
acks* {.fieldNumber: 1.}: seq[seq[byte]] acks* {.fieldNumber: 1.}: seq[seq[byte]]
offers* {.fieldNumber: 2.}: seq[seq[byte]] offers* {.fieldNumber: 2.}: seq[seq[byte]]
requests* {.fieldNumber: 3.}: seq[seq[byte]] requests* {.fieldNumber: 3.}: seq[seq[byte]]