mirror of https://github.com/vacp2p/nim-quic.git
13 lines
324 B
Nim
13 lines
324 B
Nim
import math
|
|
import stew/endians2
|
|
|
|
type
|
|
PacketNumber* = range[0'u64..2'u64^62-1]
|
|
|
|
proc toMinimalBytes*(packetnumber: PacketNumber): seq[byte] =
|
|
let bytes = packetnumber.toBytesBE
|
|
var length = bytes.len
|
|
while length > 1 and bytes[bytes.len - length] == 0:
|
|
length = length - 1
|
|
bytes[bytes.len-length..<bytes.len]
|