module

AMQP10::Protocol::Codec

Constants

DESCRIPTOR_SYMBOLS = {"amqp:header:list" => Descriptor::HEADER, "amqp:delivery-annotations:map" => Descriptor::DELIVERY_ANNOTATIONS, "amqp:message-annotations:map" => Descriptor::MESSAGE_ANNOTATIONS, "amqp:properties:list" => Descriptor::PROPERTIES, "amqp:application-properties:map" => Descriptor::APPLICATION_PROPERTIES, "amqp:data:binary" => Descriptor::DATA, "amqp:amqp-value:*" => Descriptor::AMQP_VALUE, "amqp:footer:map" => Descriptor::FOOTER, "amqp:accepted:list" => Descriptor::ACCEPTED, "amqp:rejected:list" => Descriptor::REJECTED, "amqp:released:list" => Descriptor::RELEASED, "amqp:modified:list" => Descriptor::MODIFIED}

Descriptors may be encoded either numerically (ulong code) or symbolically (ยง1.6). Map the symbolic names of every section and outcome we understand back to their numeric code so peers that describe by name interoperate.

MAX_COMPOUND_VALUES = 65536
MAX_DECODE_DEPTH = 64

Instance methods

binary_header_size(size : UInt64) : Int32
Source
binary_size(value : Bytes) : Int32
Source
decode(reader : IO::Memory) : Value
Source
described_list_size(code : UInt64, fields : Array(Value)) : Int32
Source
encoded_size(value : Value) : Int32
Source
list_header_size(fields_size) : Int32
Source
map_header_size(fields_size, count) : Int32
Source
nullable_string_size(value : String | Nil) : Int32
Source
read_binary_value(reader : IO::Memory) : Bytes
Source
read_bool_value(reader : IO::Memory) : Bool
Source
read_byte(io : IO) : UInt8

Turns IO#read_byte's nilable return into the raising form AMQP10 always wants; not a passthrough over read_bytes, so it earns its keep.

Source
read_descriptor_code(reader : IO::Memory) : UInt64
Source
read_list_header(reader : IO::Memory) : Tuple(Int32, Int32)
Source
read_map_header(reader : IO::Memory) : Tuple(Int32, Int32)
Source
read_size32(io : IO::Memory, type : String) : Int32

Reads a 32-bit size field and validates it against the remaining payload, so a hostile oversized size cannot allocate or read past the buffer.

Source
read_slice(io : IO::Memory, size : Int) : Bytes

Zero-copy view into io's own backing buffer, advancing pos past it. The slice is only valid as long as the buffer is: callers decode and retire it synchronously, so -- unlike amq-protocol's Table.from_io -- it is never defensively copied when the source is writable.

Source
read_string_value(reader : IO::Memory) : String | Nil
Source
read_uint_value(reader : IO::Memory) : UInt64
Source
skip_value(reader : IO::Memory) : Nil
Source
skip_value_payload(reader : IO::Memory, code : UInt8) : Nil

Described values are skipped iteratively: a descriptor can itself be a described value, nested without bound in untrusted input, so recursing would let a crafted value exhaust the stack.

Source
slice_from(io : IO::Memory, start : Int) : Bytes

The slice from an earlier saved position up to io's current pos.

Source
string_size(value : String) : Int32
Source
uint_size(value) : Int32
Source
write_array(io : IO, values : Array(Value)) : Nil
Source
write_binary(io : IO, value : Bytes) : Nil
Source
write_binary_header(io, size : UInt64) : Nil
Source
write_bool(io : IO, value : Bool) : Nil
Source
write_compound_header(io : IO, code8 : UInt8, code32 : UInt8, fields_size : Int32, count : Int32) : Nil
Source
write_described_list(io : IO, code : UInt64, fields : Array(Value)) : Nil
Source
write_descriptor(io : IO, code : UInt64) : Nil

Shared with TransferCodec's direct-field writers below, and with client.cr/types.cr's direct-field performative senders -- a single implementation for the "described-list header" shape used throughout AMQP 1.0's wire format, not a generic Value/Array round-trip.

Source
write_f32(io : IO, value : Float32) : Nil
Source
write_f64(io : IO, value : Float64) : Nil
Source
write_i16(io : IO, value : Int16) : Nil
Source
write_i32(io : IO, value : Int32) : Nil
Source
write_i64(io : IO, value : Int64) : Nil
Source
write_int(io : IO, value : Int64) : Nil
Source
write_list(io : IO, values : Array(Value)) : Nil
Source
write_list_header(io : IO, fields_size : Int32, count : Int32) : Nil
Source
write_long(io : IO, value : Int64) : Nil
Source
write_map(io : IO, pairs : Array(Tuple(Value, Value))) : Nil
Source
write_map_header(io, fields_size : Int32, count : Int32) : Nil
Source
write_nullable_string(io : IO, value : String | Nil) : Nil
Source
write_string(io : IO, value : String) : Nil
Source
write_symbol(io : IO, value : String) : Nil
Source
write_u16(io : IO, value : UInt16) : Nil
Source
write_u32(io : IO, value : UInt32) : Nil
Source
write_u64(io : IO, value : UInt64) : Nil
Source
write_uint(io : IO, value : UInt64) : Nil
Source
write_ulong(io : IO, value : UInt64) : Nil
Source
write_value(io : IO, value : Value) : Nil
Source

Nested types