This module implements variable buffer.
Procs
proc initVBuffer(): VBuffer {....raises: [], tags: [], forbids: [].}
- Initialize empty VBuffer. Source Edit
proc initVBuffer(data: openArray[byte]; offset = 0): VBuffer {....raises: [], tags: [], forbids: [].}
- Initialize VBuffer with copy of data. Source Edit
proc initVBuffer(data: seq[byte]; offset = 0): VBuffer {....raises: [], tags: [], forbids: [].}
- Initialize VBuffer with shallow copy of data. Source Edit
proc peekVarint(vb: var VBuffer; value: var LPSomeUVarint): int {....raises: [].}
-
Peek unsigned integer from buffer vb and store result to value.
This procedure will not adjust internal offset.
Returns number of bytes peeked from vb or -1 on error.
Source Edit proc readVarint(vb: var VBuffer; value: var LPSomeUVarint): int {.inline, ...raises: [].}
-
Read unsigned integer from buffer vb and store result to value.
Returns number of bytes consumed from vb or -1 on error.
Source Edit proc writeArray[T: byte | char](vb: var VBuffer; value: openArray[T]) {. ...raises: [].}
- Write array value to buffer vb, value will NOT be prefixed with varint length of the array. Source Edit
proc writeLPVarint(vb: var VBuffer; value: LPSomeUVarint) {....raises: [].}
- Write value as variable unsigned integer. Source Edit
proc writePBVarint(vb: var VBuffer; value: PBSomeUVarint) {....raises: [].}
- Write value as variable unsigned integer. Source Edit
proc writeVarint(vb: var VBuffer; value: LPSomeUVarint) {....raises: [].}
- Source Edit