protobuf_serialization/codec

Search:
Group by:
Source   Edit  

This module implements core primitives for the protobuf language as seen in .proto files

Types

FieldHeader = distinct uint32
Source   Edit  
fixed32 = distinct uint32
fixed-width unsigned integer Source   Edit  
fixed64 = distinct uint64
fixed-width unsigned integer Source   Edit  
pbool = distinct bool
Source   Edit  
pbytes = distinct seq[byte]
byte sequence Source   Edit  
pdouble = distinct float64
Source   Edit  
penum = distinct int32
Source   Edit  
pfloat = distinct float32
Source   Edit  
pint32 = distinct int32
varint-encoded signed integer Source   Edit  
pint64 = distinct int64
varint-encoded signed integer Source   Edit  
pstring = distinct string
UTF-8-encoded string Source   Edit  
puint32 = distinct uint32
varint-encoded unsigned integer Source   Edit  
puint64 = distinct uint64
varint-encoded unsigned integer Source   Edit  
sfixed32 = distinct int32
fixed-width signed integer Source   Edit  
sfixed64 = distinct int64
fixed-width signed integer Source   Edit  
sint32 = distinct int32
zig-zag-varint-encoded signed integer Source   Edit  
sint64 = distinct int64
zig-zag-varint-encoded signed integer Source   Edit  
SomePBInt = int32 | int64 | uint32 | uint64
Source   Edit  
SomePrimitive = SomeVarint | SomeFixed64 | SomeFixed32
Types that may appear packed Source   Edit  
WireKind = enum
  Varint = 0, Fixed64 = 1, LengthDelim = 2, Fixed32 = 5
Source   Edit  

Consts

SupportedWireKinds = {0, 1, 2, 5}
Source   Edit  

Procs

func computeSize(field: int; x: SomeScalar): int {....raises: [], gcsafe.}
Source   Edit  
func computeSize(x: FieldHeader): int {....raises: [], gcsafe, tags: [],
                                        forbids: [].}
Returns number of bytes required to encode integer x as varint. Source   Edit  
func computeSize(x: pstring | pbytes): int {....raises: [], gcsafe.}
Source   Edit  
func computeSize(x: SomeFixed64 | SomeFixed32): int {....raises: [], gcsafe.}
Returns number of bytes required to encode integer x as varint. Source   Edit  
func computeSize(x: SomeVarint): int {....raises: [], gcsafe.}
Returns number of bytes required to encode integer x as varint. Source   Edit  
proc readHeader(input: InputStream): FieldHeader {.
    ...raises: [SerializationError, IOError], raises: [], gcsafe,
    tags: [RootEffect], forbids: [].}
Source   Edit  
proc readLength(input: InputStream): int {.
    ...raises: [SerializationError, IOError], raises: [], gcsafe,
    tags: [RootEffect], forbids: [].}
Source   Edit  
proc readValue[T: SomeFixed32 | SomeFixed64](input: InputStream; _: type T): T {.
    ...raises: [SerializationError, IOError], raises: [], gcsafe.}
Source   Edit  
proc readValue[T: SomeLengthDelim](input: InputStream; _: type T): T {.
    ...raises: [SerializationError, IOError], raises: [], gcsafe.}
Source   Edit  
proc readValue[T: SomeVarint](input: InputStream; _: type T): T {.
    ...raises: [SerializationError, IOError], raises: [], gcsafe.}
Source   Edit  
proc skipValue[T: SomeFixed32 | SomeFixed64](input: InputStream; _: type T) {.
    ...raises: [SerializationError, IOError], raises: [], gcsafe.}
Source   Edit  
proc skipValue[T: SomeLengthDelim](input: InputStream; _: type T) {.
    ...raises: [SerializationError, IOError], raises: [], gcsafe.}
Source   Edit  
proc skipValue[T: SomeVarint](input: InputStream; _: type T) {.
    ...raises: [SerializationError, IOError], raises: [], gcsafe.}
Source   Edit  
proc writeField(output: OutputStream; field: int; value: SomeScalar) {.
    ...raises: [IOError], raises: [], gcsafe.}
Source   Edit  
proc writeValue(output: OutputStream; value: FieldHeader) {....raises: [IOError],
    raises: [], gcsafe, tags: [RootEffect], forbids: [].}
Source   Edit  
proc writeValue(output: OutputStream; value: pbytes) {....raises: [IOError],
    raises: [], gcsafe, tags: [RootEffect], forbids: [].}
Source   Edit  
proc writeValue(output: OutputStream; value: pstring) {....raises: [IOError],
    raises: [], gcsafe, tags: [RootEffect], forbids: [].}
Source   Edit  
proc writeValue(output: OutputStream; value: SomeFixed32) {....raises: [IOError],
    raises: [], gcsafe.}
Source   Edit  
proc writeValue(output: OutputStream; value: SomeFixed64) {....raises: [IOError],
    raises: [], gcsafe.}
Source   Edit  
proc writeValue(output: OutputStream; value: SomeVarint) {....raises: [IOError],
    raises: [], gcsafe.}
Source   Edit  

Templates

template init(_: type FieldHeader; index: int; wire: WireKind): FieldHeader {..}
Get protobuf's field header integer for index and wire. Source   Edit  
template kind(p: FieldHeader): WireKind {..}
Source   Edit  
template number(p: FieldHeader): int {..}
Source   Edit  
template toBytes(header: FieldHeader): openArray[byte] {..}
Source   Edit  
template toBytes(x: fixed32 | fixed64): openArray[byte] {..}
Source   Edit  
template toBytes(x: pdouble): openArray[byte] {..}
Source   Edit  
template toBytes(x: pfloat): openArray[byte] {..}
Source   Edit  
template toBytes(x: sfixed32): openArray[byte] {..}
Source   Edit  
template toBytes(x: sfixed64): openArray[byte] {..}
Source   Edit  
template toBytes(x: SomeVarint): openArray[byte] {..}
Source   Edit  
template validFieldNumber(i: int; strict: bool = false): bool {..}
Source   Edit  
template wireKind(T: type SomeFixed32): WireKind {..}
Source   Edit  
template wireKind(T: type SomeFixed64): WireKind {..}
Source   Edit  
template wireKind(T: type SomeLengthDelim): WireKind {..}
Source   Edit  
template wireKind(T: type SomeVarint): WireKind {..}
Source   Edit