std1.0.0-beta-7 SafeC docs

std :: serial::protobuf

Struct std::PbReader

#include <std/serial/protobuf.h> source

struct PbReader {
    []const unsigned char data;
    unsigned long pos;
}

Fields

§[]const unsigned char datasource
§unsigned long possource

Methods

§static struct PbReader new([]const unsigned char data)source · definition

A reader positioned at the start of data.

§int has_more() constsource · definition
§int read_varint(&unsigned long long out)source · definition

Each returns 1 on success, 0 on a truncated/malformed encoding (ran out of bytes mid-varint, length-delimited field's declared length exceeds the remaining buffer, etc.).

§int read_tag(&int field_num, &int wire_type)source · definition
§int read_int64(&long long out)source · definition
§int read_uint64(&unsigned long long out)source · definition
§int read_sint64(&long long out)source · definition
§int read_bool(&int out)source · definition
§int read_double(&double out)source · definition
§int read_float(&float out)source · definition
§?[]const unsigned char read_length_delimited()source · definition

The field's bytes, a slice of the reader's own buffer (see the zero-copy note above) — copy it out (e.g. String::from_bytes) if it needs to outlive that buffer. null on a truncated encoding.

§int skip_field(int wire_type)source · definition

Advances past one field's value without decoding it, given its wire type from a just-read tag — the standard "ignore fields I don't recognize" behavior every protobuf reader needs for forward compatibility with schemas that gained fields since this code was written. Returns 0 for wire type 3/4 (unsupported group markers) or a truncated encoding.