struct

Crabbit::AMQP::Encoder

Inherits Struct < Value < Object

Streaming encoder for generic AMQP 1.0 values.

The encoder writes directly to any IO. Use .encode(value) for a newly allocated Bytes result or .encode(value, io) to avoid the intermediate output allocation.

Constructors

new(io : IO = IO::Memory.new)

Creates an encoder writing to io.

Source

Class methods

encode(value : Value, io : IO) : Nil

Encodes value directly into io.

Source
encode(value : Value) : Bytes

Encodes value to a newly allocated byte slice.

Source

Instance methods

io

Returns the destination receiving encoded bytes.

Source
to_slice

Returns a copy of bytes written to an IO::Memory destination.

Raises CodecError when the encoder was constructed with another IO.

Source
write(value : Value) : self

Writes one complete AMQP value and returns self.

Source
write_described(descriptor : UInt64, value : Value) : self

Writes a numeric descriptor followed by a generic AMQP value.

Source
write_described_binary(descriptor : UInt64, value : Bytes) : self

Writes a numeric descriptor followed by AMQP binary data.

Source
write_described_list(descriptor : UInt64, values : Array(Value)) : self

Writes a numeric descriptor followed by an AMQP list.

Source
write_described_map(descriptor : UInt64, values : Hash(Value, Value)) : self

Writes a numeric descriptor followed by an AMQP map.

Source
write_described_string_map(descriptor : UInt64, values : Hash(String, Value)) : self

Writes a numeric descriptor followed by a map with AMQP string keys.

Source