std/protobuf
On this page
Index
- const
VARINT - const
FIXED64 - const
BYTES - const
START_GROUP - const
END_GROUP - const
FIXED32 - const
MAX_GROUP_DEPTH - type
ProtoErr - fn
append_varint - fn
append_tag - fn
append_fixed32 - fn
append_fixed64 - fn
append_bytes - fn
put_varint - fn
put_tag - fn
put_fixed32 - fn
put_fixed64 - fn
put_bytes - fn
size_varint - fn
encode_zigzag - fn
decode_zigzag - fn
read_varint - fn
read_tag - fn
read_fixed32 - fn
read_fixed64 - fn
read_bytes - fn
skip_field - fn
marshal - fn
unmarshal
Constants
VARINT
const VARINT: Int = 0A field’s wire type (the low three bits of its tag).
FIXED64
const FIXED64: Int = 1BYTES
const BYTES: Int = 2START_GROUP
const START_GROUP: Int = 3END_GROUP
const END_GROUP: Int = 4FIXED32
const FIXED32: Int = 5MAX_GROUP_DEPTH
const MAX_GROUP_DEPTH: Int = 10000The greatest nesting of groups skip_field follows (protowire’s 10000).
Types
ProtoErr
enum ProtoErr {
Truncated
Overflow
BadTag
BadWire(wire: Int)
EndGroup
Recursion
BadLength
Utf8
} derive DisplayWhy a wire read failed: the cases of protowire’s error codes.
Truncated the input ends inside a value, Overflow a varint is longer than ten bytes or
its tenth byte is above 1, BadTag a field number outside 1..2^29-1 or a tag over 32 bits,
BadWire a wire type of 6 or 7 (or an end group with no start), Recursion groups nested
deeper than the limit, BadLength a length that does not fit the input, Utf8 text that is
not valid UTF-8.
Functions
append_varint
fn append_varint(b: Bytes, v: UInt64) -> BytesThe bytes of v as a varint appended to b (protowire.AppendVarint).
append_tag
fn append_tag(b: Bytes, num: Int, wire: Int) -> BytesThe bytes of the tag of field num with wire type wire appended to b (AppendTag).
append_fixed32
fn append_fixed32(b: Bytes, v: UInt32) -> Bytesappend_fixed64
fn append_fixed64(b: Bytes, v: UInt64) -> Bytesappend_bytes
fn append_bytes(b: Bytes, data: Bytes) -> BytesA length prefix then the bytes (AppendBytes).
put_varint
fn put_varint(out: BytesBuilder, v: UInt64) -> BytesBuilderBuilder forms of the append functions (the generated writers of derive Proto use them: one buffer, no copy per field).
put_tag
fn put_tag(out: BytesBuilder, num: Int, wire: Int) -> BytesBuilderput_fixed32
fn put_fixed32(out: BytesBuilder, v: UInt32) -> BytesBuilderput_fixed64
fn put_fixed64(out: BytesBuilder, v: UInt64) -> BytesBuilderput_bytes
fn put_bytes(out: BytesBuilder, data: Bytes) -> BytesBuildersize_varint
fn size_varint(v: UInt64) -> IntThe number of bytes append_varint writes for v (SizeVarint).
encode_zigzag
fn encode_zigzag(v: Int) -> UInt64The zigzag form of a signed value (EncodeZigZag) and its inverse (DecodeZigZag).
decode_zigzag
fn decode_zigzag(v: UInt64) -> Intread_varint
fn read_varint(b: Bytes, at: Int) -> (UInt64, Int) ! ProtoErrThe varint at offset at of b and the offset after it (ConsumeVarint).
read_tag
fn read_tag(b: Bytes, at: Int) -> (Int, Int, Int) ! ProtoErrThe field number, wire type and the offset after the tag at at (ConsumeTag).
read_fixed32
fn read_fixed32(b: Bytes, at: Int) -> (UInt32, Int) ! ProtoErrread_fixed64
fn read_fixed64(b: Bytes, at: Int) -> (UInt64, Int) ! ProtoErrread_bytes
fn read_bytes(b: Bytes, at: Int) -> (Bytes, Int) ! ProtoErrA length prefixed value: its bytes (a view) and the offset after it (ConsumeBytes).
skip_field
fn skip_field(b: Bytes, at: Int, num: Int, wire: Int) -> Int ! ProtoErrThe offset after the value of a field with tag number num and wire type wire starting at
at, groups included (ConsumeFieldValue).
marshal
fn marshal[T: Proto](v: T) -> Bytesv as protobuf wire bytes, fields in declaration order, proto3 implicit presence (a zero
value is not written). T derives Proto (decision 0530).
unmarshal
fn unmarshal[T: Proto](data: Bytes) -> T ! ProtoErrThe T that data encodes; unknown fields are skipped, a later value of a field wins.