struct
Crabbit::AMQP::Encoder
- Crabbit::AMQP::Encoder
- Struct
- Value
- Object
Overview
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.
Defined in:
crabbit/amqp/codec.crcrabbit/amqp/message_codec.cr
Constructors
-
.new(io : IO = IO::Memory.new)
Creates an encoder writing to io.
Class Method Summary
-
.encode(value : Value, io : IO) : Nil
Encodes value directly into io.
-
.encode(value : Value) : Bytes
Encodes value to a newly allocated byte slice.
Instance Method Summary
-
#io : IO
Returns the destination receiving encoded bytes.
-
#to_slice : Bytes
Returns a copy of bytes written to an
IO::Memorydestination. -
#write(value : Value) : self
Writes one complete AMQP value and returns
self. -
#write_described(descriptor : UInt64, value : Value) : self
Writes a numeric descriptor followed by a generic AMQP value.
-
#write_described_binary(descriptor : UInt64, value : Bytes) : self
Writes a numeric descriptor followed by AMQP binary data.
-
#write_described_list(descriptor : UInt64, values : Array(Value)) : self
Writes a numeric descriptor followed by an AMQP list.
-
#write_described_map(descriptor : UInt64, values : Hash(Value, Value)) : self
Writes a numeric descriptor followed by an AMQP map.
-
#write_described_string_map(descriptor : UInt64, values : Hash(String, Value)) : self
Writes a numeric descriptor followed by a map with AMQP string keys.
Constructor Detail
Class Method Detail
Encodes value to a newly allocated byte slice.
Instance Method Detail
Returns a copy of bytes written to an IO::Memory destination.
Raises CodecError when the encoder was constructed with another IO.
Writes a numeric descriptor followed by a generic AMQP value.
Writes a numeric descriptor followed by AMQP binary data.
Writes a numeric descriptor followed by an AMQP list.
Writes a numeric descriptor followed by an AMQP map.
Writes a numeric descriptor followed by a map with AMQP string keys.