GitHub

API reference for reader.

Reads the protobuf wire format (Effect's protobuf/ProtobufReader).

A ProtobufReader reads one value at a time from bytes: a tag, then the value its wire type says. delimited gives a reader of one length-delimited value, bounded to it, and skip passes over a value of an unknown field. Malformed input raises ProtobufReaderError with the offset where reading stopped.

The input is untrusted: a varint is at most ten bytes, a tag or a length at most 32 bits, and a length never reaches past the end of its message. skip passes over groups with an explicit stack, nested at most max_depth deep (512 by default).

64-bit integers come as int; the *_number methods give a float, rounded as JavaScript's Number rounds a bigint.

Classes

Functions

field_number

field_number(tag) -> int
ParameterTypeDescription
tagint

Returns int

def field_number(tag: int) -> int:
    return tag >> 3

wire_type

wire_type(tag) -> WireType
ParameterTypeDescription
tagint

Returns WireType

def wire_type(tag: int) -> WireType:
    return WireType(tag & 7)

make

make(data) -> ProtobufReader

A reader of data, which it borrows: bytes_view shows changes to it.

ParameterTypeDescription
data_Bytes | bytearray | memoryview

Returns ProtobufReader

def make(data: _Bytes | bytearray | memoryview) -> ProtobufReader:
    """A reader of ``data``, which it borrows: ``bytes_view`` shows changes to it."""
    return ProtobufReader(data)