This module implements core primitives for the protobuf language as seen in .proto files
Types
FieldHeader = distinct uint32
- Source Edit
SomePrimitive = SomeVarint | SomeFixed64 | SomeFixed32
- Types that may appear packed 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: SomeVarint): openArray[byte] {..}
- Source Edit
template validFieldNumber(i: int; strict: bool = false): bool {..}
- Source Edit
Exports
-
ProtobufMessageError, pint, ProtobufError, fieldNumber, sint, pbSome, required, ProtobufExt, implicit, ProtobufReader, ProtobufWriter, ext, pbNone, init, oneof, PBExplicit, ProtobufValueError, init, get, isSome, proto3, PBOption, valueOr, ProtobufGroupError, finish, isNone, mget, ProtobufEOFError, ProtobufFlags, pbSome, packed, fixed, toValue, proto2, ProtobufReadError, proto, init