Nim-Libp2p Copyright (c) 2018 Status Research & Development GmbH
- Licensed under either of
- Apache License, version 2.0, (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option. This file may not be copied, modified, or distributed except according to those terms.
This module implements variable buffer.Procs
proc initVBuffer(): VBuffer {....raises: [Defect], tags: [].}
- Initialize empty VBuffer. Source Edit
proc initVBuffer(data: openArray[byte]; offset = 0): VBuffer {....raises: [Defect], tags: [].}
- Initialize VBuffer with copy of data. Source Edit
proc initVBuffer(data: seq[byte]; offset = 0): VBuffer {....raises: [Defect], tags: [].}
- Initialize VBuffer with shallow copy of data. Source Edit
proc peekVarint(vb: var VBuffer; value: var LPSomeUVarint): int {. ...raises: [Defect].}
-
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: [Defect].}
-
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: [Defect].}
- 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: [Defect].}
- Write value as variable unsigned integer. Source Edit
proc writePBVarint(vb: var VBuffer; value: PBSomeUVarint) {....raises: [Defect].}
- Write value as variable unsigned integer. Source Edit
proc writeVarint(vb: var VBuffer; value: LPSomeUVarint) {....raises: [Defect].}
- Source Edit