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| Parameter | Type | Description |
|---|---|---|
tag | int |
Returns int
def field_number(tag: int) -> int:
return tag >> 3wire_type#
wire_type(tag) -> WireType| Parameter | Type | Description |
|---|---|---|
tag | int |
Returns WireType
def wire_type(tag: int) -> WireType:
return WireType(tag & 7)make#
make(data) -> ProtobufReaderA reader of data, which it borrows: bytes_view shows changes to it.
| Parameter | Type | Description |
|---|---|---|
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)