class

Crabbit::AMQP::Value

Inherits Reference < Object

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

Constructors

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.

Source
described(descriptor, value) : Value

Wraps descriptor and value and returns an AMQP described value.

Source
list(values : Enumerable) : Value

Wraps each item in values and returns an AMQP list.

Source
map(values : Hash) : Value

Wraps every key and value and returns an AMQP map.

Source
new(kind : Kind, payload : Payload = nil)

Creates and validates a value for kind and payload.

Source
null

Returns the AMQP null value.

Source
symbol(value : String) : Value

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

Source
wrap(value : Value) : Value

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

Source
wrap(value : Nil) : Value

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

Source
wrap(value : Bool) : Value

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

Source
wrap(value : UInt8) : Value

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

Source
wrap(value : UInt16) : Value

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

Source
wrap(value : UInt32) : Value

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

Source
wrap(value : UInt64) : Value

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

Source
wrap(value : Int8) : Value

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

Source
wrap(value : Int16) : Value

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

Source
wrap(value : Int32) : Value

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

Source
wrap(value : Int64) : Value

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

Source
wrap(value : Float32) : Value

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

Source
wrap(value : Float64) : Value

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

Source
wrap(value : Char) : Value

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

Source
wrap(value : Time) : Value

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

Source
wrap(value : UUID) : Value

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

Source
wrap(value : Bytes) : Value

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

Binary input is copied.

Source
wrap(value : String) : Value

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

Source

Instance methods

==(other : self)

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

hash(hasher)

See Object#hash(hasher)

kind

Returns the AMQP type kind.

Source
payload

Returns the typed Crystal payload.

Source

Nested types