struct

Proto::Wire::Reader

Inherits Struct < Value < Object

Reader wraps an IO and provides typed protobuf wire-format read primitives.

Entry point for message decode loops is read_tag, which returns nil on clean EOF (end of message) and raises DecodeError on malformed input. All other read methods raise DecodeError on unexpected EOF.

Constants

DEFAULT_MAX_FIELD_LENGTH = (8 * 1024) * 1024
DEFAULT_MAX_MESSAGE_SIZE = (64_i64 * 1024) * 1024
MAX_FIELD_NUMBER = 536870911

Constructors

new(io : IO, max_message_size : Int64 = DEFAULT_MAX_MESSAGE_SIZE, max_field_length : Int32 = DEFAULT_MAX_FIELD_LENGTH)
Source

Class methods

int32_from_varint(raw : UInt64) : Int32
Source

Instance methods

expect_wire_type!(field_number : Int32, wire_type : Int32, expected_wire_type : Int32, alternate_wire_type : Int32) : Nil
Source
expect_wire_type!(field_number : Int32, wire_type : Int32, expected_wire_type : Int32) : Nil
Source
packed_wire_type?(field_number : Int32, wire_type : Int32, unpacked_wire_type : Int32) : Bool
Source
read_bool
Source
read_bytes
Source
read_double
Source
read_embedded

Return a scoped IO::Memory over the next length-delimited field. The bytes are consumed from this reader immediately.

Source
read_embedded(field_number : Int32, wire_type : Int32, & : IO::Memory -> T) : T forall T
Source
read_fixed32
Source
read_fixed64
Source
read_float
Source
read_int32

int32 / int64 use sign-extended varint

Source
read_int64
Source
read_packed_double

Decode a packed repeated double field.

Source
read_packed_fixed32

Decode a packed repeated fixed32 field.

Source
read_packed_fixed64

Decode a packed repeated fixed64 field.

Source
read_packed_float

Decode a packed repeated float field.

Source
read_packed_sfixed32

Decode a packed repeated sfixed32 field.

Source
read_packed_sfixed64

Decode a packed repeated sfixed64 field.

Source
read_packed_varint

Decode a packed repeated varint field into the given array. Yields each decoded UInt64 raw value; callers convert as needed.

Source
read_sfixed32
Source
read_sfixed64
Source
read_sint32

sint32 / sint64 use zigzag encoding

Source
read_sint64
Source
read_string
Source
read_tag

Read the next field tag. Returns {field_number, wire_type}, or nil on clean EOF.

Source
read_uint32

uint32 / uint64 use plain varint

Source
read_uint64
Source
read_unknown_field(field_number : Int32, wire_type : Int32) : UnknownField
Source
skip_field(wire_type : Int32) : Nil

Skip one untagged field value of the given wire type.

Source
skip_tag(tag : Tuple(Int32, Int32)) : Nil

Skip one tagged field value with strict START_GROUP/END_GROUP matching.

Source