func (m *Message) MarshalBinary() ([]byte, error) {
	buf := new(buffer)
	err := m.marshal(buf)
	return buf.b, err
}
MarshalBinary encodes the message into binary form.
package amqp
import (
	"encoding/binary"
	"encoding/hex"
	"fmt"
	"math"
	"reflect"
	"time"
	"unicode/utf8"
)
type amqpType uint8
type ProtoID uint8
const (
	typeCodeNull amqpType = 0x40
	typeCodeBool      amqpType = 0x56  
	typeCodeBoolTrue  amqpType = 0x41
	typeCodeBoolFalse amqpType = 0x42
	typeCodeUbyte      amqpType = 0x50  
	typeCodeUshort     amqpType = 0x60  
	typeCodeUint       amqpType = 0x70  
	typeCodeSmallUint  amqpType = 0x52  
	typeCodeUint0      amqpType = 0x43  
	typeCodeUlong      amqpType = 0x80  
	typeCodeSmallUlong amqpType = 0x53  
	typeCodeUlong0     amqpType = 0x44  
	typeCodeByte      amqpType = 0x51  
	typeCodeShort     amqpType = 0x61  
	typeCodeInt       amqpType = 0x71  
	typeCodeSmallint  amqpType = 0x54  
	typeCodeLong      amqpType = 0x81  
	typeCodeSmalllong amqpType = 0x55  
	typeCodeFloat      amqpType = 0x72  
	typeCodeDouble     amqpType = 0x82  
	typeCodeDecimal32  amqpType = 0x74  
	typeCodeDecimal64  amqpType = 0x84  
	typeCodeDecimal128 amqpType = 0x94  
	typeCodeChar      amqpType = 0x73  
	typeCodeTimestamp amqpType = 0x83  
	typeCodeUUID      amqpType = 0x98  
	typeCodeVbin8  amqpType = 0xa0  
	typeCodeVbin32 amqpType = 0xb0  
	typeCodeStr8   amqpType = 0xa1  
	typeCodeStr32  amqpType = 0xb1  
	typeCodeSym8   amqpType = 0xa3  
	typeCodeSym32  amqpType = 0xb3  
	typeCodeList0   amqpType = 0x45  
	typeCodeList8   amqpType = 0xc0  
	typeCodeList32  amqpType = 0xd0  
	typeCodeMap8    amqpType = 0xc1  
	typeCodeMap32   amqpType = 0xd1  
	typeCodeArray8  amqpType = 0xe0  
	typeCodeArray32 amqpType = 0xf0  
	typeCodeOpen        amqpType = 0x10
	typeCodeBegin       amqpType = 0x11
	typeCodeAttach      amqpType = 0x12
	typeCodeFlow        amqpType = 0x13
	typeCodeTransfer    amqpType = 0x14
	typeCodeDisposition amqpType = 0x15
	typeCodeDetach      amqpType = 0x16
	typeCodeEnd         amqpType = 0x17
	typeCodeClose       amqpType = 0x18
	typeCodeSource amqpType = 0x28
	typeCodeTarget amqpType = 0x29
	typeCodeError  amqpType = 0x1d
	typeCodeMessageHeader         amqpType = 0x70
	typeCodeDeliveryAnnotations   amqpType = 0x71
	typeCodeMessageAnnotations    amqpType = 0x72
	typeCodeMessageProperties     amqpType = 0x73
	typeCodeApplicationProperties amqpType = 0x74
	typeCodeApplicationData       amqpType = 0x75
	typeCodeAMQPSequence          amqpType = 0x76
	typeCodeAMQPValue             amqpType = 0x77
	typeCodeFooter                amqpType = 0x78
	typeCodeStateReceived amqpType = 0x23
	typeCodeStateAccepted amqpType = 0x24
	typeCodeStateRejected amqpType = 0x25
	typeCodeStateReleased amqpType = 0x26
	typeCodeStateModified amqpType = 0x27
	typeCodeSASLMechanism amqpType = 0x40
	typeCodeSASLInit      amqpType = 0x41
	typeCodeSASLChallenge amqpType = 0x42
	typeCodeSASLResponse  amqpType = 0x43
	typeCodeSASLOutcome   amqpType = 0x44
	typeCodeDeleteOnClose             amqpType = 0x2b
	typeCodeDeleteOnNoLinks           amqpType = 0x2c
	typeCodeDeleteOnNoMessages        amqpType = 0x2d
	typeCodeDeleteOnNoLinksOrMessages amqpType = 0x2e
)
type deliveryState interface{}  
type unsettled map[string]deliveryState
func (u unsettled) marshal(wr *buffer) error {
	return writeMap(wr, u)
}
func (u *unsettled) unmarshal(r *buffer) error {
	count, err := readMapHeader(r)
	if err != nil {
		return err
	}
	m := make(unsettled, count/2)
	for i := uint32(0); i < count; i += 2 {
		key, err := readString(r)
		if err != nil {
			return err
		}
		var value deliveryState
		err = unmarshal(r, &value)
		if err != nil {
			return err
		}
		m[key] = value
	}
	*u = m
	return nil
}
type filter map[symbol]*describedType
func (f filter) marshal(wr *buffer) error {
	return writeMap(wr, f)
}
func (f *filter) unmarshal(r *buffer) error {
	count, err := readMapHeader(r)
	if err != nil {
		return err
	}
	m := make(filter, count/2)
	for i := uint32(0); i < count; i += 2 {
		key, err := readString(r)
		if err != nil {
			return err
		}
		var value describedType
		err = unmarshal(r, &value)
		if err != nil {
			return err
		}
		m[symbol(key)] = &value
	}
	*f = m
	return nil
}
type ErrorCondition string
func (ec ErrorCondition) marshal(wr *buffer) error {
	return (symbol)(ec).marshal(wr)
}
func (ec *ErrorCondition) unmarshal(r *buffer) error {
	s, err := readString(r)
	*ec = ErrorCondition(s)
	return err
}
const (
	ErrorInternalError         ErrorCondition = "amqp:internal-error"
	ErrorNotFound              ErrorCondition = "amqp:not-found"
	ErrorUnauthorizedAccess    ErrorCondition = "amqp:unauthorized-access"
	ErrorDecodeError           ErrorCondition = "amqp:decode-error"
	ErrorResourceLimitExceeded ErrorCondition = "amqp:resource-limit-exceeded"
	ErrorNotAllowed            ErrorCondition = "amqp:not-allowed"
	ErrorInvalidField          ErrorCondition = "amqp:invalid-field"
	ErrorNotImplemented        ErrorCondition = "amqp:not-implemented"
	ErrorResourceLocked        ErrorCondition = "amqp:resource-locked"
	ErrorPreconditionFailed    ErrorCondition = "amqp:precondition-failed"
	ErrorResourceDeleted       ErrorCondition = "amqp:resource-deleted"
	ErrorIllegalState          ErrorCondition = "amqp:illegal-state"
	ErrorFrameSizeTooSmall     ErrorCondition = "amqp:frame-size-too-small"
	ErrorConnectionForced   ErrorCondition = "amqp:connection:forced"
	ErrorFramingError       ErrorCondition = "amqp:connection:framing-error"
	ErrorConnectionRedirect ErrorCondition = "amqp:connection:redirect"
	ErrorWindowViolation  ErrorCondition = "amqp:session:window-violation"
	ErrorErrantLink       ErrorCondition = "amqp:session:errant-link"
	ErrorHandleInUse      ErrorCondition = "amqp:session:handle-in-use"
	ErrorUnattachedHandle ErrorCondition = "amqp:session:unattached-handle"
	ErrorDetachForced          ErrorCondition = "amqp:link:detach-forced"
	ErrorTransferLimitExceeded ErrorCondition = "amqp:link:transfer-limit-exceeded"
	ErrorMessageSizeExceeded   ErrorCondition = "amqp:link:message-size-exceeded"
	ErrorLinkRedirect          ErrorCondition = "amqp:link:redirect"
	ErrorStolen                ErrorCondition = "amqp:link:stolen"
)
type Error struct {
	Condition ErrorCondition
	Description string
	Info map[string]interface{}
}
func (e *Error) marshal(wr *buffer) error {
	return marshalComposite(wr, typeCodeError, []marshalField{
		{value: &e.Condition, omit: false},
		{value: &e.Description, omit: e.Description == ""},
		{value: e.Info, omit: len(e.Info) == 0},
	})
}
func (e *Error) unmarshal(r *buffer) error {
	return unmarshalComposite(r, typeCodeError, []unmarshalField{
		{field: &e.Condition, handleNull: func() error { return errorNew("Error.Condition is required") }},
		{field: &e.Description},
		{field: &e.Info},
	}...)
}
func (e *Error) String() string {
	if e == nil {
		return "*Error(nil)"
	}
	return fmt.Sprintf("*Error{Condition: %s, Description: %s, Info: %v}",
		e.Condition,
		e.Description,
		e.Info,
	)
}
func (e *Error) Error() string {
	return e.String()
}
type Message struct {
	Format uint32
	DeliveryTag []byte
	Header *MessageHeader
	DeliveryAnnotations Annotations
	Annotations Annotations
	Properties *MessageProperties
	ApplicationProperties map[string]interface{}
	Data [][]byte
	Value interface{}
	Footer Annotations
	SendSettled bool
	settled bool  
	doneSignal chan struct{}
}
type AMQP10 struct {
	publishingId    int64
	hasPublishingId bool
	message         *Message
	Properties      *MessageProperties
}
func NewMessage(data []byte) *AMQP10 {
	return &AMQP10{
		message:         newMessage(data),
		publishingId:    0,
		hasPublishingId: false,
	}
}
func (amqp *AMQP10) SetPublishingId(id int64) {
	amqp.hasPublishingId = true
	amqp.publishingId = id
}
func (amqp *AMQP10) HasPublishingId() bool {
	return amqp.hasPublishingId
}
func (amqp *AMQP10) GetPublishingId() int64 {
	return amqp.publishingId
}
func (amqp *AMQP10) MarshalBinary() ([]byte, error) {
	amqp.message.Properties = amqp.Properties
	return amqp.message.MarshalBinary()
}
func (amqp *AMQP10) UnmarshalBinary(data []byte) error {
	return amqp.message.UnmarshalBinary(data)
}
func (amqp *AMQP10) GetData() [][]byte {
	return amqp.message.Data
}
func (amqp *AMQP10) Message() *Message {
	return amqp.message
}
func newMessage(data []byte) *Message {
	return &Message{
		Data:       [][]byte{data},
		doneSignal: make(chan struct{}),
	}
}
func (m *Message) done() {
	if m.doneSignal != nil {
		close(m.doneSignal)
	}
}
func (m *Message) GetData() []byte {
	if len(m.Data) < 1 {
		return nil
	}
	return m.Data[0]
}
func (m *Message) Ignore() {
	if m.shouldSendDisposition() {
		m.done()
	}
}