src/iwork/wire

Source   Edit  

Types

WireKind = enum
  wkVarint,                 ## wire type 0
  wkFixed64,                ## wire type 1
  wkBytes,                  ## wire type 2 (length-delimited)
  wkFixed32                  ## wire type 5
Source   Edit  
WireMessage = object
  fields*: Table[int, seq[WireValue]]
a decoded message: field number to every occurrence of that field Source   Edit  
WireValue = object
  case kind*: WireKind
  of wkVarint:
    varint*: uint64
  of wkFixed64:
    fixed64*: uint64
  of wkBytes:
    bytes*: string
  of wkFixed32:
    fixed32*: uint32
one decoded field occurrence Source   Edit  

Procs

proc decodeMessage(data: string): WireMessage {....raises: [IworkFormatError],
    tags: [], forbids: [].}
decodes a whole message into the generic field tree, raising IworkFormatError on malformed wire data Source   Edit  
func getDouble(msg: WireMessage; field: int): Option[float64] {....raises: [],
    tags: [], forbids: [].}
first fixed64 occurrence as float64 Source   Edit  
func getFloat(msg: WireMessage; field: int): Option[float32] {....raises: [],
    tags: [], forbids: [].}
first fixed32 occurrence as float32 Source   Edit  
func getInt(msg: WireMessage; field: int; zigzag = false): Option[int64] {.
    ...raises: [], tags: [], forbids: [].}
first varint occurrence as signed, zigzag-decoded when asked Source   Edit  
proc getMessage(msg: WireMessage; field: int): Option[WireMessage] {.
    ...raises: [IworkFormatError], tags: [], forbids: [].}
lazily decodes the first length-delimited occurrence as a nested message Source   Edit  
func getRepeatedDouble(msg: WireMessage; field: int): seq[float64] {....raises: [],
    tags: [], forbids: [].}
every fixed64 occurrence as float64 Source   Edit  
func getRepeatedFloat(msg: WireMessage; field: int): seq[float32] {....raises: [],
    tags: [], forbids: [].}
every fixed32 occurrence as float32 Source   Edit  
func getRepeatedInt(msg: WireMessage; field: int; zigzag = false): seq[int64] {.
    ...raises: [], tags: [], forbids: [].}
every varint occurrence as signed Source   Edit  
proc getRepeatedMessage(msg: WireMessage; field: int): seq[WireMessage] {.
    ...raises: [IworkFormatError], tags: [], forbids: [].}
every length-delimited occurrence decoded as a nested message Source   Edit  
func getRepeatedString(msg: WireMessage; field: int): seq[string] {....raises: [],
    tags: [], forbids: [].}
every length-delimited occurrence as raw bytes/string Source   Edit  
func getRepeatedUint(msg: WireMessage; field: int): seq[uint64] {....raises: [],
    tags: [], forbids: [].}
every varint occurrence of a field Source   Edit  
func getString(msg: WireMessage; field: int): Option[string] {....raises: [],
    tags: [], forbids: [].}
first length-delimited occurrence as raw bytes/string Source   Edit  
func getUint(msg: WireMessage; field: int): Option[uint64] {....raises: [],
    tags: [], forbids: [].}
first varint occurrence of a field as unsigned Source   Edit  
proc readVarint(data: string; offset: var int): uint64 {.
    ...raises: [IworkFormatError], tags: [], forbids: [].}
reads one varint starting at offset, advancing it past the bytes read Source   Edit