class Crabbit::AMQP::Value

Overview

Dynamically typed AMQP 1.0 value.

.wrap maps Crystal primitive values to their canonical AMQP kinds. Explicit constructors provide Symbol, List, Map, Array, and Described values. The constructor validates that payload matches kind.

value = Crabbit::AMQP::Value.map({
  "attempt" => 3_u32,
  "ready"   => true,
})
encoded = Crabbit::AMQP::Encoder.encode(value)
decoded = Crabbit::AMQP::Decoder.new(encoded).read

Defined in:

crabbit/amqp/value.cr

Constructors

Instance Method Summary

Constructor Detail

def self.array(values : Enumerable) : Value #

Wraps each item and returns a homogeneous AMQP array.

The encoder rejects empty arrays and arrays whose values use different AMQP constructors.


[View source]
def self.described(descriptor, value) : Value #

Wraps descriptor and value and returns an AMQP described value.


[View source]
def self.list(values : Enumerable) : Value #

Wraps each item in values and returns an AMQP list.


[View source]
def self.map(values : Hash) : Value #

Wraps every key and value and returns an AMQP map.


[View source]
def self.new(kind : Kind, payload : Payload = nil) #

Creates and validates a value for kind and payload.


[View source]
def self.null : self #

Returns the AMQP null value.


[View source]
def self.symbol(value : String) : Value #

Returns an AMQP symbol after validating it during encoding as ASCII.


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

Returns value unchanged, or wraps a supported Crystal primitive in its canonical AMQP kind.


[View source]
def self.wrap(value : Nil) : Value #

Returns value unchanged, or wraps a supported Crystal primitive in its canonical AMQP kind.


[View source]
def self.wrap(value : Bool) : Value #

Returns value unchanged, or wraps a supported Crystal primitive in its canonical AMQP kind.


[View source]
def self.wrap(value : UInt8) : Value #

Returns value unchanged, or wraps a supported Crystal primitive in its canonical AMQP kind.


[View source]
def self.wrap(value : UInt16) : Value #

Returns value unchanged, or wraps a supported Crystal primitive in its canonical AMQP kind.


[View source]
def self.wrap(value : UInt32) : Value #

Returns value unchanged, or wraps a supported Crystal primitive in its canonical AMQP kind.


[View source]
def self.wrap(value : UInt64) : Value #

Returns value unchanged, or wraps a supported Crystal primitive in its canonical AMQP kind.


[View source]
def self.wrap(value : Int8) : Value #

Returns value unchanged, or wraps a supported Crystal primitive in its canonical AMQP kind.


[View source]
def self.wrap(value : Int16) : Value #

Returns value unchanged, or wraps a supported Crystal primitive in its canonical AMQP kind.


[View source]
def self.wrap(value : Int32) : Value #

Returns value unchanged, or wraps a supported Crystal primitive in its canonical AMQP kind.


[View source]
def self.wrap(value : Int64) : Value #

Returns value unchanged, or wraps a supported Crystal primitive in its canonical AMQP kind.


[View source]
def self.wrap(value : Float32) : Value #

Returns value unchanged, or wraps a supported Crystal primitive in its canonical AMQP kind.


[View source]
def self.wrap(value : Float64) : Value #

Returns value unchanged, or wraps a supported Crystal primitive in its canonical AMQP kind.


[View source]
def self.wrap(value : Char) : Value #

Returns value unchanged, or wraps a supported Crystal primitive in its canonical AMQP kind.


[View source]
def self.wrap(value : Time) : Value #

Returns value unchanged, or wraps a supported Crystal primitive in its canonical AMQP kind.


[View source]
def self.wrap(value : UUID) : Value #

Returns value unchanged, or wraps a supported Crystal primitive in its canonical AMQP kind.


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

Returns value unchanged, or wraps a supported Crystal primitive in its canonical AMQP kind.

Binary input is copied.


[View source]
def self.wrap(value : String) : Value #

Returns value unchanged, or wraps a supported Crystal primitive in its canonical AMQP kind.


[View source]

Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def kind : Kind #

Returns the AMQP type kind.


[View source]
def payload : Payload #

Returns the typed Crystal payload.


[View source]