struct Crabbit::AMQP::Encoder

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.cr
crabbit/amqp/message_codec.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(io : IO = IO::Memory.new) #

Creates an encoder writing to io.


[View source]

Class Method Detail

def self.encode(value : Value, io : IO) : Nil #

Encodes value directly into io.


[View source]
def self.encode(value : Value) : Bytes #

Encodes value to a newly allocated byte slice.


[View source]

Instance Method Detail

def io : IO #

Returns the destination receiving encoded bytes.


[View source]
def to_slice : Bytes #

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

Raises CodecError when the encoder was constructed with another IO.


[View source]
def write(value : Value) : self #

Writes one complete AMQP value and returns self.


[View source]
def write_described(descriptor : UInt64, value : Value) : self #

Writes a numeric descriptor followed by a generic AMQP value.


[View source]
def write_described_binary(descriptor : UInt64, value : Bytes) : self #

Writes a numeric descriptor followed by AMQP binary data.


[View source]
def write_described_list(descriptor : UInt64, values : Array(Value)) : self #

Writes a numeric descriptor followed by an AMQP list.


[View source]
def write_described_map(descriptor : UInt64, values : Hash(Value, Value)) : self #

Writes a numeric descriptor followed by an AMQP map.


[View source]
def write_described_string_map(descriptor : UInt64, values : Hash(String, Value)) : self #

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


[View source]