src: Add DMA localagent
[barometer.git] / src / dma / vendor / github.com / streadway / amqp / spec091.go
1 // Copyright (c) 2012, Sean Treadway, SoundCloud Ltd.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4 // Source code and contact info at http://github.com/streadway/amqp
5
6 /* GENERATED FILE - DO NOT EDIT */
7 /* Rebuild from the spec/gen.go tool */
8
9 package amqp
10
11 import (
12         "encoding/binary"
13         "fmt"
14         "io"
15 )
16
17 // Error codes that can be sent from the server during a connection or
18 // channel exception or used by the client to indicate a class of error like
19 // ErrCredentials.  The text of the error is likely more interesting than
20 // these constants.
21 const (
22         frameMethod        = 1
23         frameHeader        = 2
24         frameBody          = 3
25         frameHeartbeat     = 8
26         frameMinSize       = 4096
27         frameEnd           = 206
28         replySuccess       = 200
29         ContentTooLarge    = 311
30         NoRoute            = 312
31         NoConsumers        = 313
32         ConnectionForced   = 320
33         InvalidPath        = 402
34         AccessRefused      = 403
35         NotFound           = 404
36         ResourceLocked     = 405
37         PreconditionFailed = 406
38         FrameError         = 501
39         SyntaxError        = 502
40         CommandInvalid     = 503
41         ChannelError       = 504
42         UnexpectedFrame    = 505
43         ResourceError      = 506
44         NotAllowed         = 530
45         NotImplemented     = 540
46         InternalError      = 541
47 )
48
49 func isSoftExceptionCode(code int) bool {
50         switch code {
51         case 311:
52                 return true
53         case 312:
54                 return true
55         case 313:
56                 return true
57         case 403:
58                 return true
59         case 404:
60                 return true
61         case 405:
62                 return true
63         case 406:
64                 return true
65
66         }
67         return false
68 }
69
70 type connectionStart struct {
71         VersionMajor     byte
72         VersionMinor     byte
73         ServerProperties Table
74         Mechanisms       string
75         Locales          string
76 }
77
78 func (msg *connectionStart) id() (uint16, uint16) {
79         return 10, 10
80 }
81
82 func (msg *connectionStart) wait() bool {
83         return true
84 }
85
86 func (msg *connectionStart) write(w io.Writer) (err error) {
87
88         if err = binary.Write(w, binary.BigEndian, msg.VersionMajor); err != nil {
89                 return
90         }
91         if err = binary.Write(w, binary.BigEndian, msg.VersionMinor); err != nil {
92                 return
93         }
94
95         if err = writeTable(w, msg.ServerProperties); err != nil {
96                 return
97         }
98
99         if err = writeLongstr(w, msg.Mechanisms); err != nil {
100                 return
101         }
102         if err = writeLongstr(w, msg.Locales); err != nil {
103                 return
104         }
105
106         return
107 }
108
109 func (msg *connectionStart) read(r io.Reader) (err error) {
110
111         if err = binary.Read(r, binary.BigEndian, &msg.VersionMajor); err != nil {
112                 return
113         }
114         if err = binary.Read(r, binary.BigEndian, &msg.VersionMinor); err != nil {
115                 return
116         }
117
118         if msg.ServerProperties, err = readTable(r); err != nil {
119                 return
120         }
121
122         if msg.Mechanisms, err = readLongstr(r); err != nil {
123                 return
124         }
125         if msg.Locales, err = readLongstr(r); err != nil {
126                 return
127         }
128
129         return
130 }
131
132 type connectionStartOk struct {
133         ClientProperties Table
134         Mechanism        string
135         Response         string
136         Locale           string
137 }
138
139 func (msg *connectionStartOk) id() (uint16, uint16) {
140         return 10, 11
141 }
142
143 func (msg *connectionStartOk) wait() bool {
144         return true
145 }
146
147 func (msg *connectionStartOk) write(w io.Writer) (err error) {
148
149         if err = writeTable(w, msg.ClientProperties); err != nil {
150                 return
151         }
152
153         if err = writeShortstr(w, msg.Mechanism); err != nil {
154                 return
155         }
156
157         if err = writeLongstr(w, msg.Response); err != nil {
158                 return
159         }
160
161         if err = writeShortstr(w, msg.Locale); err != nil {
162                 return
163         }
164
165         return
166 }
167
168 func (msg *connectionStartOk) read(r io.Reader) (err error) {
169
170         if msg.ClientProperties, err = readTable(r); err != nil {
171                 return
172         }
173
174         if msg.Mechanism, err = readShortstr(r); err != nil {
175                 return
176         }
177
178         if msg.Response, err = readLongstr(r); err != nil {
179                 return
180         }
181
182         if msg.Locale, err = readShortstr(r); err != nil {
183                 return
184         }
185
186         return
187 }
188
189 type connectionSecure struct {
190         Challenge string
191 }
192
193 func (msg *connectionSecure) id() (uint16, uint16) {
194         return 10, 20
195 }
196
197 func (msg *connectionSecure) wait() bool {
198         return true
199 }
200
201 func (msg *connectionSecure) write(w io.Writer) (err error) {
202
203         if err = writeLongstr(w, msg.Challenge); err != nil {
204                 return
205         }
206
207         return
208 }
209
210 func (msg *connectionSecure) read(r io.Reader) (err error) {
211
212         if msg.Challenge, err = readLongstr(r); err != nil {
213                 return
214         }
215
216         return
217 }
218
219 type connectionSecureOk struct {
220         Response string
221 }
222
223 func (msg *connectionSecureOk) id() (uint16, uint16) {
224         return 10, 21
225 }
226
227 func (msg *connectionSecureOk) wait() bool {
228         return true
229 }
230
231 func (msg *connectionSecureOk) write(w io.Writer) (err error) {
232
233         if err = writeLongstr(w, msg.Response); err != nil {
234                 return
235         }
236
237         return
238 }
239
240 func (msg *connectionSecureOk) read(r io.Reader) (err error) {
241
242         if msg.Response, err = readLongstr(r); err != nil {
243                 return
244         }
245
246         return
247 }
248
249 type connectionTune struct {
250         ChannelMax uint16
251         FrameMax   uint32
252         Heartbeat  uint16
253 }
254
255 func (msg *connectionTune) id() (uint16, uint16) {
256         return 10, 30
257 }
258
259 func (msg *connectionTune) wait() bool {
260         return true
261 }
262
263 func (msg *connectionTune) write(w io.Writer) (err error) {
264
265         if err = binary.Write(w, binary.BigEndian, msg.ChannelMax); err != nil {
266                 return
267         }
268
269         if err = binary.Write(w, binary.BigEndian, msg.FrameMax); err != nil {
270                 return
271         }
272
273         if err = binary.Write(w, binary.BigEndian, msg.Heartbeat); err != nil {
274                 return
275         }
276
277         return
278 }
279
280 func (msg *connectionTune) read(r io.Reader) (err error) {
281
282         if err = binary.Read(r, binary.BigEndian, &msg.ChannelMax); err != nil {
283                 return
284         }
285
286         if err = binary.Read(r, binary.BigEndian, &msg.FrameMax); err != nil {
287                 return
288         }
289
290         if err = binary.Read(r, binary.BigEndian, &msg.Heartbeat); err != nil {
291                 return
292         }
293
294         return
295 }
296
297 type connectionTuneOk struct {
298         ChannelMax uint16
299         FrameMax   uint32
300         Heartbeat  uint16
301 }
302
303 func (msg *connectionTuneOk) id() (uint16, uint16) {
304         return 10, 31
305 }
306
307 func (msg *connectionTuneOk) wait() bool {
308         return true
309 }
310
311 func (msg *connectionTuneOk) write(w io.Writer) (err error) {
312
313         if err = binary.Write(w, binary.BigEndian, msg.ChannelMax); err != nil {
314                 return
315         }
316
317         if err = binary.Write(w, binary.BigEndian, msg.FrameMax); err != nil {
318                 return
319         }
320
321         if err = binary.Write(w, binary.BigEndian, msg.Heartbeat); err != nil {
322                 return
323         }
324
325         return
326 }
327
328 func (msg *connectionTuneOk) read(r io.Reader) (err error) {
329
330         if err = binary.Read(r, binary.BigEndian, &msg.ChannelMax); err != nil {
331                 return
332         }
333
334         if err = binary.Read(r, binary.BigEndian, &msg.FrameMax); err != nil {
335                 return
336         }
337
338         if err = binary.Read(r, binary.BigEndian, &msg.Heartbeat); err != nil {
339                 return
340         }
341
342         return
343 }
344
345 type connectionOpen struct {
346         VirtualHost string
347         reserved1   string
348         reserved2   bool
349 }
350
351 func (msg *connectionOpen) id() (uint16, uint16) {
352         return 10, 40
353 }
354
355 func (msg *connectionOpen) wait() bool {
356         return true
357 }
358
359 func (msg *connectionOpen) write(w io.Writer) (err error) {
360         var bits byte
361
362         if err = writeShortstr(w, msg.VirtualHost); err != nil {
363                 return
364         }
365         if err = writeShortstr(w, msg.reserved1); err != nil {
366                 return
367         }
368
369         if msg.reserved2 {
370                 bits |= 1 << 0
371         }
372
373         if err = binary.Write(w, binary.BigEndian, bits); err != nil {
374                 return
375         }
376
377         return
378 }
379
380 func (msg *connectionOpen) read(r io.Reader) (err error) {
381         var bits byte
382
383         if msg.VirtualHost, err = readShortstr(r); err != nil {
384                 return
385         }
386         if msg.reserved1, err = readShortstr(r); err != nil {
387                 return
388         }
389
390         if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
391                 return
392         }
393         msg.reserved2 = (bits&(1<<0) > 0)
394
395         return
396 }
397
398 type connectionOpenOk struct {
399         reserved1 string
400 }
401
402 func (msg *connectionOpenOk) id() (uint16, uint16) {
403         return 10, 41
404 }
405
406 func (msg *connectionOpenOk) wait() bool {
407         return true
408 }
409
410 func (msg *connectionOpenOk) write(w io.Writer) (err error) {
411
412         if err = writeShortstr(w, msg.reserved1); err != nil {
413                 return
414         }
415
416         return
417 }
418
419 func (msg *connectionOpenOk) read(r io.Reader) (err error) {
420
421         if msg.reserved1, err = readShortstr(r); err != nil {
422                 return
423         }
424
425         return
426 }
427
428 type connectionClose struct {
429         ReplyCode uint16
430         ReplyText string
431         ClassId   uint16
432         MethodId  uint16
433 }
434
435 func (msg *connectionClose) id() (uint16, uint16) {
436         return 10, 50
437 }
438
439 func (msg *connectionClose) wait() bool {
440         return true
441 }
442
443 func (msg *connectionClose) write(w io.Writer) (err error) {
444
445         if err = binary.Write(w, binary.BigEndian, msg.ReplyCode); err != nil {
446                 return
447         }
448
449         if err = writeShortstr(w, msg.ReplyText); err != nil {
450                 return
451         }
452
453         if err = binary.Write(w, binary.BigEndian, msg.ClassId); err != nil {
454                 return
455         }
456         if err = binary.Write(w, binary.BigEndian, msg.MethodId); err != nil {
457                 return
458         }
459
460         return
461 }
462
463 func (msg *connectionClose) read(r io.Reader) (err error) {
464
465         if err = binary.Read(r, binary.BigEndian, &msg.ReplyCode); err != nil {
466                 return
467         }
468
469         if msg.ReplyText, err = readShortstr(r); err != nil {
470                 return
471         }
472
473         if err = binary.Read(r, binary.BigEndian, &msg.ClassId); err != nil {
474                 return
475         }
476         if err = binary.Read(r, binary.BigEndian, &msg.MethodId); err != nil {
477                 return
478         }
479
480         return
481 }
482
483 type connectionCloseOk struct {
484 }
485
486 func (msg *connectionCloseOk) id() (uint16, uint16) {
487         return 10, 51
488 }
489
490 func (msg *connectionCloseOk) wait() bool {
491         return true
492 }
493
494 func (msg *connectionCloseOk) write(w io.Writer) (err error) {
495
496         return
497 }
498
499 func (msg *connectionCloseOk) read(r io.Reader) (err error) {
500
501         return
502 }
503
504 type connectionBlocked struct {
505         Reason string
506 }
507
508 func (msg *connectionBlocked) id() (uint16, uint16) {
509         return 10, 60
510 }
511
512 func (msg *connectionBlocked) wait() bool {
513         return false
514 }
515
516 func (msg *connectionBlocked) write(w io.Writer) (err error) {
517
518         if err = writeShortstr(w, msg.Reason); err != nil {
519                 return
520         }
521
522         return
523 }
524
525 func (msg *connectionBlocked) read(r io.Reader) (err error) {
526
527         if msg.Reason, err = readShortstr(r); err != nil {
528                 return
529         }
530
531         return
532 }
533
534 type connectionUnblocked struct {
535 }
536
537 func (msg *connectionUnblocked) id() (uint16, uint16) {
538         return 10, 61
539 }
540
541 func (msg *connectionUnblocked) wait() bool {
542         return false
543 }
544
545 func (msg *connectionUnblocked) write(w io.Writer) (err error) {
546
547         return
548 }
549
550 func (msg *connectionUnblocked) read(r io.Reader) (err error) {
551
552         return
553 }
554
555 type channelOpen struct {
556         reserved1 string
557 }
558
559 func (msg *channelOpen) id() (uint16, uint16) {
560         return 20, 10
561 }
562
563 func (msg *channelOpen) wait() bool {
564         return true
565 }
566
567 func (msg *channelOpen) write(w io.Writer) (err error) {
568
569         if err = writeShortstr(w, msg.reserved1); err != nil {
570                 return
571         }
572
573         return
574 }
575
576 func (msg *channelOpen) read(r io.Reader) (err error) {
577
578         if msg.reserved1, err = readShortstr(r); err != nil {
579                 return
580         }
581
582         return
583 }
584
585 type channelOpenOk struct {
586         reserved1 string
587 }
588
589 func (msg *channelOpenOk) id() (uint16, uint16) {
590         return 20, 11
591 }
592
593 func (msg *channelOpenOk) wait() bool {
594         return true
595 }
596
597 func (msg *channelOpenOk) write(w io.Writer) (err error) {
598
599         if err = writeLongstr(w, msg.reserved1); err != nil {
600                 return
601         }
602
603         return
604 }
605
606 func (msg *channelOpenOk) read(r io.Reader) (err error) {
607
608         if msg.reserved1, err = readLongstr(r); err != nil {
609                 return
610         }
611
612         return
613 }
614
615 type channelFlow struct {
616         Active bool
617 }
618
619 func (msg *channelFlow) id() (uint16, uint16) {
620         return 20, 20
621 }
622
623 func (msg *channelFlow) wait() bool {
624         return true
625 }
626
627 func (msg *channelFlow) write(w io.Writer) (err error) {
628         var bits byte
629
630         if msg.Active {
631                 bits |= 1 << 0
632         }
633
634         if err = binary.Write(w, binary.BigEndian, bits); err != nil {
635                 return
636         }
637
638         return
639 }
640
641 func (msg *channelFlow) read(r io.Reader) (err error) {
642         var bits byte
643
644         if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
645                 return
646         }
647         msg.Active = (bits&(1<<0) > 0)
648
649         return
650 }
651
652 type channelFlowOk struct {
653         Active bool
654 }
655
656 func (msg *channelFlowOk) id() (uint16, uint16) {
657         return 20, 21
658 }
659
660 func (msg *channelFlowOk) wait() bool {
661         return false
662 }
663
664 func (msg *channelFlowOk) write(w io.Writer) (err error) {
665         var bits byte
666
667         if msg.Active {
668                 bits |= 1 << 0
669         }
670
671         if err = binary.Write(w, binary.BigEndian, bits); err != nil {
672                 return
673         }
674
675         return
676 }
677
678 func (msg *channelFlowOk) read(r io.Reader) (err error) {
679         var bits byte
680
681         if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
682                 return
683         }
684         msg.Active = (bits&(1<<0) > 0)
685
686         return
687 }
688
689 type channelClose struct {
690         ReplyCode uint16
691         ReplyText string
692         ClassId   uint16
693         MethodId  uint16
694 }
695
696 func (msg *channelClose) id() (uint16, uint16) {
697         return 20, 40
698 }
699
700 func (msg *channelClose) wait() bool {
701         return true
702 }
703
704 func (msg *channelClose) write(w io.Writer) (err error) {
705
706         if err = binary.Write(w, binary.BigEndian, msg.ReplyCode); err != nil {
707                 return
708         }
709
710         if err = writeShortstr(w, msg.ReplyText); err != nil {
711                 return
712         }
713
714         if err = binary.Write(w, binary.BigEndian, msg.ClassId); err != nil {
715                 return
716         }
717         if err = binary.Write(w, binary.BigEndian, msg.MethodId); err != nil {
718                 return
719         }
720
721         return
722 }
723
724 func (msg *channelClose) read(r io.Reader) (err error) {
725
726         if err = binary.Read(r, binary.BigEndian, &msg.ReplyCode); err != nil {
727                 return
728         }
729
730         if msg.ReplyText, err = readShortstr(r); err != nil {
731                 return
732         }
733
734         if err = binary.Read(r, binary.BigEndian, &msg.ClassId); err != nil {
735                 return
736         }
737         if err = binary.Read(r, binary.BigEndian, &msg.MethodId); err != nil {
738                 return
739         }
740
741         return
742 }
743
744 type channelCloseOk struct {
745 }
746
747 func (msg *channelCloseOk) id() (uint16, uint16) {
748         return 20, 41
749 }
750
751 func (msg *channelCloseOk) wait() bool {
752         return true
753 }
754
755 func (msg *channelCloseOk) write(w io.Writer) (err error) {
756
757         return
758 }
759
760 func (msg *channelCloseOk) read(r io.Reader) (err error) {
761
762         return
763 }
764
765 type exchangeDeclare struct {
766         reserved1  uint16
767         Exchange   string
768         Type       string
769         Passive    bool
770         Durable    bool
771         AutoDelete bool
772         Internal   bool
773         NoWait     bool
774         Arguments  Table
775 }
776
777 func (msg *exchangeDeclare) id() (uint16, uint16) {
778         return 40, 10
779 }
780
781 func (msg *exchangeDeclare) wait() bool {
782         return true && !msg.NoWait
783 }
784
785 func (msg *exchangeDeclare) write(w io.Writer) (err error) {
786         var bits byte
787
788         if err = binary.Write(w, binary.BigEndian, msg.reserved1); err != nil {
789                 return
790         }
791
792         if err = writeShortstr(w, msg.Exchange); err != nil {
793                 return
794         }
795         if err = writeShortstr(w, msg.Type); err != nil {
796                 return
797         }
798
799         if msg.Passive {
800                 bits |= 1 << 0
801         }
802
803         if msg.Durable {
804                 bits |= 1 << 1
805         }
806
807         if msg.AutoDelete {
808                 bits |= 1 << 2
809         }
810
811         if msg.Internal {
812                 bits |= 1 << 3
813         }
814
815         if msg.NoWait {
816                 bits |= 1 << 4
817         }
818
819         if err = binary.Write(w, binary.BigEndian, bits); err != nil {
820                 return
821         }
822
823         if err = writeTable(w, msg.Arguments); err != nil {
824                 return
825         }
826
827         return
828 }
829
830 func (msg *exchangeDeclare) read(r io.Reader) (err error) {
831         var bits byte
832
833         if err = binary.Read(r, binary.BigEndian, &msg.reserved1); err != nil {
834                 return
835         }
836
837         if msg.Exchange, err = readShortstr(r); err != nil {
838                 return
839         }
840         if msg.Type, err = readShortstr(r); err != nil {
841                 return
842         }
843
844         if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
845                 return
846         }
847         msg.Passive = (bits&(1<<0) > 0)
848         msg.Durable = (bits&(1<<1) > 0)
849         msg.AutoDelete = (bits&(1<<2) > 0)
850         msg.Internal = (bits&(1<<3) > 0)
851         msg.NoWait = (bits&(1<<4) > 0)
852
853         if msg.Arguments, err = readTable(r); err != nil {
854                 return
855         }
856
857         return
858 }
859
860 type exchangeDeclareOk struct {
861 }
862
863 func (msg *exchangeDeclareOk) id() (uint16, uint16) {
864         return 40, 11
865 }
866
867 func (msg *exchangeDeclareOk) wait() bool {
868         return true
869 }
870
871 func (msg *exchangeDeclareOk) write(w io.Writer) (err error) {
872
873         return
874 }
875
876 func (msg *exchangeDeclareOk) read(r io.Reader) (err error) {
877
878         return
879 }
880
881 type exchangeDelete struct {
882         reserved1 uint16
883         Exchange  string
884         IfUnused  bool
885         NoWait    bool
886 }
887
888 func (msg *exchangeDelete) id() (uint16, uint16) {
889         return 40, 20
890 }
891
892 func (msg *exchangeDelete) wait() bool {
893         return true && !msg.NoWait
894 }
895
896 func (msg *exchangeDelete) write(w io.Writer) (err error) {
897         var bits byte
898
899         if err = binary.Write(w, binary.BigEndian, msg.reserved1); err != nil {
900                 return
901         }
902
903         if err = writeShortstr(w, msg.Exchange); err != nil {
904                 return
905         }
906
907         if msg.IfUnused {
908                 bits |= 1 << 0
909         }
910
911         if msg.NoWait {
912                 bits |= 1 << 1
913         }
914
915         if err = binary.Write(w, binary.BigEndian, bits); err != nil {
916                 return
917         }
918
919         return
920 }
921
922 func (msg *exchangeDelete) read(r io.Reader) (err error) {
923         var bits byte
924
925         if err = binary.Read(r, binary.BigEndian, &msg.reserved1); err != nil {
926                 return
927         }
928
929         if msg.Exchange, err = readShortstr(r); err != nil {
930                 return
931         }
932
933         if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
934                 return
935         }
936         msg.IfUnused = (bits&(1<<0) > 0)
937         msg.NoWait = (bits&(1<<1) > 0)
938
939         return
940 }
941
942 type exchangeDeleteOk struct {
943 }
944
945 func (msg *exchangeDeleteOk) id() (uint16, uint16) {
946         return 40, 21
947 }
948
949 func (msg *exchangeDeleteOk) wait() bool {
950         return true
951 }
952
953 func (msg *exchangeDeleteOk) write(w io.Writer) (err error) {
954
955         return
956 }
957
958 func (msg *exchangeDeleteOk) read(r io.Reader) (err error) {
959
960         return
961 }
962
963 type exchangeBind struct {
964         reserved1   uint16
965         Destination string
966         Source      string
967         RoutingKey  string
968         NoWait      bool
969         Arguments   Table
970 }
971
972 func (msg *exchangeBind) id() (uint16, uint16) {
973         return 40, 30
974 }
975
976 func (msg *exchangeBind) wait() bool {
977         return true && !msg.NoWait
978 }
979
980 func (msg *exchangeBind) write(w io.Writer) (err error) {
981         var bits byte
982
983         if err = binary.Write(w, binary.BigEndian, msg.reserved1); err != nil {
984                 return
985         }
986
987         if err = writeShortstr(w, msg.Destination); err != nil {
988                 return
989         }
990         if err = writeShortstr(w, msg.Source); err != nil {
991                 return
992         }
993         if err = writeShortstr(w, msg.RoutingKey); err != nil {
994                 return
995         }
996
997         if msg.NoWait {
998                 bits |= 1 << 0
999         }
1000
1001         if err = binary.Write(w, binary.BigEndian, bits); err != nil {
1002                 return
1003         }
1004
1005         if err = writeTable(w, msg.Arguments); err != nil {
1006                 return
1007         }
1008
1009         return
1010 }
1011
1012 func (msg *exchangeBind) read(r io.Reader) (err error) {
1013         var bits byte
1014
1015         if err = binary.Read(r, binary.BigEndian, &msg.reserved1); err != nil {
1016                 return
1017         }
1018
1019         if msg.Destination, err = readShortstr(r); err != nil {
1020                 return
1021         }
1022         if msg.Source, err = readShortstr(r); err != nil {
1023                 return
1024         }
1025         if msg.RoutingKey, err = readShortstr(r); err != nil {
1026                 return
1027         }
1028
1029         if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
1030                 return
1031         }
1032         msg.NoWait = (bits&(1<<0) > 0)
1033
1034         if msg.Arguments, err = readTable(r); err != nil {
1035                 return
1036         }
1037
1038         return
1039 }
1040
1041 type exchangeBindOk struct {
1042 }
1043
1044 func (msg *exchangeBindOk) id() (uint16, uint16) {
1045         return 40, 31
1046 }
1047
1048 func (msg *exchangeBindOk) wait() bool {
1049         return true
1050 }
1051
1052 func (msg *exchangeBindOk) write(w io.Writer) (err error) {
1053
1054         return
1055 }
1056
1057 func (msg *exchangeBindOk) read(r io.Reader) (err error) {
1058
1059         return
1060 }
1061
1062 type exchangeUnbind struct {
1063         reserved1   uint16
1064         Destination string
1065         Source      string
1066         RoutingKey  string
1067         NoWait      bool
1068         Arguments   Table
1069 }
1070
1071 func (msg *exchangeUnbind) id() (uint16, uint16) {
1072         return 40, 40
1073 }
1074
1075 func (msg *exchangeUnbind) wait() bool {
1076         return true && !msg.NoWait
1077 }
1078
1079 func (msg *exchangeUnbind) write(w io.Writer) (err error) {
1080         var bits byte
1081
1082         if err = binary.Write(w, binary.BigEndian, msg.reserved1); err != nil {
1083                 return
1084         }
1085
1086         if err = writeShortstr(w, msg.Destination); err != nil {
1087                 return
1088         }
1089         if err = writeShortstr(w, msg.Source); err != nil {
1090                 return
1091         }
1092         if err = writeShortstr(w, msg.RoutingKey); err != nil {
1093                 return
1094         }
1095
1096         if msg.NoWait {
1097                 bits |= 1 << 0
1098         }
1099
1100         if err = binary.Write(w, binary.BigEndian, bits); err != nil {
1101                 return
1102         }
1103
1104         if err = writeTable(w, msg.Arguments); err != nil {
1105                 return
1106         }
1107
1108         return
1109 }
1110
1111 func (msg *exchangeUnbind) read(r io.Reader) (err error) {
1112         var bits byte
1113
1114         if err = binary.Read(r, binary.BigEndian, &msg.reserved1); err != nil {
1115                 return
1116         }
1117
1118         if msg.Destination, err = readShortstr(r); err != nil {
1119                 return
1120         }
1121         if msg.Source, err = readShortstr(r); err != nil {
1122                 return
1123         }
1124         if msg.RoutingKey, err = readShortstr(r); err != nil {
1125                 return
1126         }
1127
1128         if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
1129                 return
1130         }
1131         msg.NoWait = (bits&(1<<0) > 0)
1132
1133         if msg.Arguments, err = readTable(r); err != nil {
1134                 return
1135         }
1136
1137         return
1138 }
1139
1140 type exchangeUnbindOk struct {
1141 }
1142
1143 func (msg *exchangeUnbindOk) id() (uint16, uint16) {
1144         return 40, 51
1145 }
1146
1147 func (msg *exchangeUnbindOk) wait() bool {
1148         return true
1149 }
1150
1151 func (msg *exchangeUnbindOk) write(w io.Writer) (err error) {
1152
1153         return
1154 }
1155
1156 func (msg *exchangeUnbindOk) read(r io.Reader) (err error) {
1157
1158         return
1159 }
1160
1161 type queueDeclare struct {
1162         reserved1  uint16
1163         Queue      string
1164         Passive    bool
1165         Durable    bool
1166         Exclusive  bool
1167         AutoDelete bool
1168         NoWait     bool
1169         Arguments  Table
1170 }
1171
1172 func (msg *queueDeclare) id() (uint16, uint16) {
1173         return 50, 10
1174 }
1175
1176 func (msg *queueDeclare) wait() bool {
1177         return true && !msg.NoWait
1178 }
1179
1180 func (msg *queueDeclare) write(w io.Writer) (err error) {
1181         var bits byte
1182
1183         if err = binary.Write(w, binary.BigEndian, msg.reserved1); err != nil {
1184                 return
1185         }
1186
1187         if err = writeShortstr(w, msg.Queue); err != nil {
1188                 return
1189         }
1190
1191         if msg.Passive {
1192                 bits |= 1 << 0
1193         }
1194
1195         if msg.Durable {
1196                 bits |= 1 << 1
1197         }
1198
1199         if msg.Exclusive {
1200                 bits |= 1 << 2
1201         }
1202
1203         if msg.AutoDelete {
1204                 bits |= 1 << 3
1205         }
1206
1207         if msg.NoWait {
1208                 bits |= 1 << 4
1209         }
1210
1211         if err = binary.Write(w, binary.BigEndian, bits); err != nil {
1212                 return
1213         }
1214
1215         if err = writeTable(w, msg.Arguments); err != nil {
1216                 return
1217         }
1218
1219         return
1220 }
1221
1222 func (msg *queueDeclare) read(r io.Reader) (err error) {
1223         var bits byte
1224
1225         if err = binary.Read(r, binary.BigEndian, &msg.reserved1); err != nil {
1226                 return
1227         }
1228
1229         if msg.Queue, err = readShortstr(r); err != nil {
1230                 return
1231         }
1232
1233         if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
1234                 return
1235         }
1236         msg.Passive = (bits&(1<<0) > 0)
1237         msg.Durable = (bits&(1<<1) > 0)
1238         msg.Exclusive = (bits&(1<<2) > 0)
1239         msg.AutoDelete = (bits&(1<<3) > 0)
1240         msg.NoWait = (bits&(1<<4) > 0)
1241
1242         if msg.Arguments, err = readTable(r); err != nil {
1243                 return
1244         }
1245
1246         return
1247 }
1248
1249 type queueDeclareOk struct {
1250         Queue         string
1251         MessageCount  uint32
1252         ConsumerCount uint32
1253 }
1254
1255 func (msg *queueDeclareOk) id() (uint16, uint16) {
1256         return 50, 11
1257 }
1258
1259 func (msg *queueDeclareOk) wait() bool {
1260         return true
1261 }
1262
1263 func (msg *queueDeclareOk) write(w io.Writer) (err error) {
1264
1265         if err = writeShortstr(w, msg.Queue); err != nil {
1266                 return
1267         }
1268
1269         if err = binary.Write(w, binary.BigEndian, msg.MessageCount); err != nil {
1270                 return
1271         }
1272         if err = binary.Write(w, binary.BigEndian, msg.ConsumerCount); err != nil {
1273                 return
1274         }
1275
1276         return
1277 }
1278
1279 func (msg *queueDeclareOk) read(r io.Reader) (err error) {
1280
1281         if msg.Queue, err = readShortstr(r); err != nil {
1282                 return
1283         }
1284
1285         if err = binary.Read(r, binary.BigEndian, &msg.MessageCount); err != nil {
1286                 return
1287         }
1288         if err = binary.Read(r, binary.BigEndian, &msg.ConsumerCount); err != nil {
1289                 return
1290         }
1291
1292         return
1293 }
1294
1295 type queueBind struct {
1296         reserved1  uint16
1297         Queue      string
1298         Exchange   string
1299         RoutingKey string
1300         NoWait     bool
1301         Arguments  Table
1302 }
1303
1304 func (msg *queueBind) id() (uint16, uint16) {
1305         return 50, 20
1306 }
1307
1308 func (msg *queueBind) wait() bool {
1309         return true && !msg.NoWait
1310 }
1311
1312 func (msg *queueBind) write(w io.Writer) (err error) {
1313         var bits byte
1314
1315         if err = binary.Write(w, binary.BigEndian, msg.reserved1); err != nil {
1316                 return
1317         }
1318
1319         if err = writeShortstr(w, msg.Queue); err != nil {
1320                 return
1321         }
1322         if err = writeShortstr(w, msg.Exchange); err != nil {
1323                 return
1324         }
1325         if err = writeShortstr(w, msg.RoutingKey); err != nil {
1326                 return
1327         }
1328
1329         if msg.NoWait {
1330                 bits |= 1 << 0
1331         }
1332
1333         if err = binary.Write(w, binary.BigEndian, bits); err != nil {
1334                 return
1335         }
1336
1337         if err = writeTable(w, msg.Arguments); err != nil {
1338                 return
1339         }
1340
1341         return
1342 }
1343
1344 func (msg *queueBind) read(r io.Reader) (err error) {
1345         var bits byte
1346
1347         if err = binary.Read(r, binary.BigEndian, &msg.reserved1); err != nil {
1348                 return
1349         }
1350
1351         if msg.Queue, err = readShortstr(r); err != nil {
1352                 return
1353         }
1354         if msg.Exchange, err = readShortstr(r); err != nil {
1355                 return
1356         }
1357         if msg.RoutingKey, err = readShortstr(r); err != nil {
1358                 return
1359         }
1360
1361         if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
1362                 return
1363         }
1364         msg.NoWait = (bits&(1<<0) > 0)
1365
1366         if msg.Arguments, err = readTable(r); err != nil {
1367                 return
1368         }
1369
1370         return
1371 }
1372
1373 type queueBindOk struct {
1374 }
1375
1376 func (msg *queueBindOk) id() (uint16, uint16) {
1377         return 50, 21
1378 }
1379
1380 func (msg *queueBindOk) wait() bool {
1381         return true
1382 }
1383
1384 func (msg *queueBindOk) write(w io.Writer) (err error) {
1385
1386         return
1387 }
1388
1389 func (msg *queueBindOk) read(r io.Reader) (err error) {
1390
1391         return
1392 }
1393
1394 type queueUnbind struct {
1395         reserved1  uint16
1396         Queue      string
1397         Exchange   string
1398         RoutingKey string
1399         Arguments  Table
1400 }
1401
1402 func (msg *queueUnbind) id() (uint16, uint16) {
1403         return 50, 50
1404 }
1405
1406 func (msg *queueUnbind) wait() bool {
1407         return true
1408 }
1409
1410 func (msg *queueUnbind) write(w io.Writer) (err error) {
1411
1412         if err = binary.Write(w, binary.BigEndian, msg.reserved1); err != nil {
1413                 return
1414         }
1415
1416         if err = writeShortstr(w, msg.Queue); err != nil {
1417                 return
1418         }
1419         if err = writeShortstr(w, msg.Exchange); err != nil {
1420                 return
1421         }
1422         if err = writeShortstr(w, msg.RoutingKey); err != nil {
1423                 return
1424         }
1425
1426         if err = writeTable(w, msg.Arguments); err != nil {
1427                 return
1428         }
1429
1430         return
1431 }
1432
1433 func (msg *queueUnbind) read(r io.Reader) (err error) {
1434
1435         if err = binary.Read(r, binary.BigEndian, &msg.reserved1); err != nil {
1436                 return
1437         }
1438
1439         if msg.Queue, err = readShortstr(r); err != nil {
1440                 return
1441         }
1442         if msg.Exchange, err = readShortstr(r); err != nil {
1443                 return
1444         }
1445         if msg.RoutingKey, err = readShortstr(r); err != nil {
1446                 return
1447         }
1448
1449         if msg.Arguments, err = readTable(r); err != nil {
1450                 return
1451         }
1452
1453         return
1454 }
1455
1456 type queueUnbindOk struct {
1457 }
1458
1459 func (msg *queueUnbindOk) id() (uint16, uint16) {
1460         return 50, 51
1461 }
1462
1463 func (msg *queueUnbindOk) wait() bool {
1464         return true
1465 }
1466
1467 func (msg *queueUnbindOk) write(w io.Writer) (err error) {
1468
1469         return
1470 }
1471
1472 func (msg *queueUnbindOk) read(r io.Reader) (err error) {
1473
1474         return
1475 }
1476
1477 type queuePurge struct {
1478         reserved1 uint16
1479         Queue     string
1480         NoWait    bool
1481 }
1482
1483 func (msg *queuePurge) id() (uint16, uint16) {
1484         return 50, 30
1485 }
1486
1487 func (msg *queuePurge) wait() bool {
1488         return true && !msg.NoWait
1489 }
1490
1491 func (msg *queuePurge) write(w io.Writer) (err error) {
1492         var bits byte
1493
1494         if err = binary.Write(w, binary.BigEndian, msg.reserved1); err != nil {
1495                 return
1496         }
1497
1498         if err = writeShortstr(w, msg.Queue); err != nil {
1499                 return
1500         }
1501
1502         if msg.NoWait {
1503                 bits |= 1 << 0
1504         }
1505
1506         if err = binary.Write(w, binary.BigEndian, bits); err != nil {
1507                 return
1508         }
1509
1510         return
1511 }
1512
1513 func (msg *queuePurge) read(r io.Reader) (err error) {
1514         var bits byte
1515
1516         if err = binary.Read(r, binary.BigEndian, &msg.reserved1); err != nil {
1517                 return
1518         }
1519
1520         if msg.Queue, err = readShortstr(r); err != nil {
1521                 return
1522         }
1523
1524         if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
1525                 return
1526         }
1527         msg.NoWait = (bits&(1<<0) > 0)
1528
1529         return
1530 }
1531
1532 type queuePurgeOk struct {
1533         MessageCount uint32
1534 }
1535
1536 func (msg *queuePurgeOk) id() (uint16, uint16) {
1537         return 50, 31
1538 }
1539
1540 func (msg *queuePurgeOk) wait() bool {
1541         return true
1542 }
1543
1544 func (msg *queuePurgeOk) write(w io.Writer) (err error) {
1545
1546         if err = binary.Write(w, binary.BigEndian, msg.MessageCount); err != nil {
1547                 return
1548         }
1549
1550         return
1551 }
1552
1553 func (msg *queuePurgeOk) read(r io.Reader) (err error) {
1554
1555         if err = binary.Read(r, binary.BigEndian, &msg.MessageCount); err != nil {
1556                 return
1557         }
1558
1559         return
1560 }
1561
1562 type queueDelete struct {
1563         reserved1 uint16
1564         Queue     string
1565         IfUnused  bool
1566         IfEmpty   bool
1567         NoWait    bool
1568 }
1569
1570 func (msg *queueDelete) id() (uint16, uint16) {
1571         return 50, 40
1572 }
1573
1574 func (msg *queueDelete) wait() bool {
1575         return true && !msg.NoWait
1576 }
1577
1578 func (msg *queueDelete) write(w io.Writer) (err error) {
1579         var bits byte
1580
1581         if err = binary.Write(w, binary.BigEndian, msg.reserved1); err != nil {
1582                 return
1583         }
1584
1585         if err = writeShortstr(w, msg.Queue); err != nil {
1586                 return
1587         }
1588
1589         if msg.IfUnused {
1590                 bits |= 1 << 0
1591         }
1592
1593         if msg.IfEmpty {
1594                 bits |= 1 << 1
1595         }
1596
1597         if msg.NoWait {
1598                 bits |= 1 << 2
1599         }
1600
1601         if err = binary.Write(w, binary.BigEndian, bits); err != nil {
1602                 return
1603         }
1604
1605         return
1606 }
1607
1608 func (msg *queueDelete) read(r io.Reader) (err error) {
1609         var bits byte
1610
1611         if err = binary.Read(r, binary.BigEndian, &msg.reserved1); err != nil {
1612                 return
1613         }
1614
1615         if msg.Queue, err = readShortstr(r); err != nil {
1616                 return
1617         }
1618
1619         if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
1620                 return
1621         }
1622         msg.IfUnused = (bits&(1<<0) > 0)
1623         msg.IfEmpty = (bits&(1<<1) > 0)
1624         msg.NoWait = (bits&(1<<2) > 0)
1625
1626         return
1627 }
1628
1629 type queueDeleteOk struct {
1630         MessageCount uint32
1631 }
1632
1633 func (msg *queueDeleteOk) id() (uint16, uint16) {
1634         return 50, 41
1635 }
1636
1637 func (msg *queueDeleteOk) wait() bool {
1638         return true
1639 }
1640
1641 func (msg *queueDeleteOk) write(w io.Writer) (err error) {
1642
1643         if err = binary.Write(w, binary.BigEndian, msg.MessageCount); err != nil {
1644                 return
1645         }
1646
1647         return
1648 }
1649
1650 func (msg *queueDeleteOk) read(r io.Reader) (err error) {
1651
1652         if err = binary.Read(r, binary.BigEndian, &msg.MessageCount); err != nil {
1653                 return
1654         }
1655
1656         return
1657 }
1658
1659 type basicQos struct {
1660         PrefetchSize  uint32
1661         PrefetchCount uint16
1662         Global        bool
1663 }
1664
1665 func (msg *basicQos) id() (uint16, uint16) {
1666         return 60, 10
1667 }
1668
1669 func (msg *basicQos) wait() bool {
1670         return true
1671 }
1672
1673 func (msg *basicQos) write(w io.Writer) (err error) {
1674         var bits byte
1675
1676         if err = binary.Write(w, binary.BigEndian, msg.PrefetchSize); err != nil {
1677                 return
1678         }
1679
1680         if err = binary.Write(w, binary.BigEndian, msg.PrefetchCount); err != nil {
1681                 return
1682         }
1683
1684         if msg.Global {
1685                 bits |= 1 << 0
1686         }
1687
1688         if err = binary.Write(w, binary.BigEndian, bits); err != nil {
1689                 return
1690         }
1691
1692         return
1693 }
1694
1695 func (msg *basicQos) read(r io.Reader) (err error) {
1696         var bits byte
1697
1698         if err = binary.Read(r, binary.BigEndian, &msg.PrefetchSize); err != nil {
1699                 return
1700         }
1701
1702         if err = binary.Read(r, binary.BigEndian, &msg.PrefetchCount); err != nil {
1703                 return
1704         }
1705
1706         if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
1707                 return
1708         }
1709         msg.Global = (bits&(1<<0) > 0)
1710
1711         return
1712 }
1713
1714 type basicQosOk struct {
1715 }
1716
1717 func (msg *basicQosOk) id() (uint16, uint16) {
1718         return 60, 11
1719 }
1720
1721 func (msg *basicQosOk) wait() bool {
1722         return true
1723 }
1724
1725 func (msg *basicQosOk) write(w io.Writer) (err error) {
1726
1727         return
1728 }
1729
1730 func (msg *basicQosOk) read(r io.Reader) (err error) {
1731
1732         return
1733 }
1734
1735 type basicConsume struct {
1736         reserved1   uint16
1737         Queue       string
1738         ConsumerTag string
1739         NoLocal     bool
1740         NoAck       bool
1741         Exclusive   bool
1742         NoWait      bool
1743         Arguments   Table
1744 }
1745
1746 func (msg *basicConsume) id() (uint16, uint16) {
1747         return 60, 20
1748 }
1749
1750 func (msg *basicConsume) wait() bool {
1751         return true && !msg.NoWait
1752 }
1753
1754 func (msg *basicConsume) write(w io.Writer) (err error) {
1755         var bits byte
1756
1757         if err = binary.Write(w, binary.BigEndian, msg.reserved1); err != nil {
1758                 return
1759         }
1760
1761         if err = writeShortstr(w, msg.Queue); err != nil {
1762                 return
1763         }
1764         if err = writeShortstr(w, msg.ConsumerTag); err != nil {
1765                 return
1766         }
1767
1768         if msg.NoLocal {
1769                 bits |= 1 << 0
1770         }
1771
1772         if msg.NoAck {
1773                 bits |= 1 << 1
1774         }
1775
1776         if msg.Exclusive {
1777                 bits |= 1 << 2
1778         }
1779
1780         if msg.NoWait {
1781                 bits |= 1 << 3
1782         }
1783
1784         if err = binary.Write(w, binary.BigEndian, bits); err != nil {
1785                 return
1786         }
1787
1788         if err = writeTable(w, msg.Arguments); err != nil {
1789                 return
1790         }
1791
1792         return
1793 }
1794
1795 func (msg *basicConsume) read(r io.Reader) (err error) {
1796         var bits byte
1797
1798         if err = binary.Read(r, binary.BigEndian, &msg.reserved1); err != nil {
1799                 return
1800         }
1801
1802         if msg.Queue, err = readShortstr(r); err != nil {
1803                 return
1804         }
1805         if msg.ConsumerTag, err = readShortstr(r); err != nil {
1806                 return
1807         }
1808
1809         if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
1810                 return
1811         }
1812         msg.NoLocal = (bits&(1<<0) > 0)
1813         msg.NoAck = (bits&(1<<1) > 0)
1814         msg.Exclusive = (bits&(1<<2) > 0)
1815         msg.NoWait = (bits&(1<<3) > 0)
1816
1817         if msg.Arguments, err = readTable(r); err != nil {
1818                 return
1819         }
1820
1821         return
1822 }
1823
1824 type basicConsumeOk struct {
1825         ConsumerTag string
1826 }
1827
1828 func (msg *basicConsumeOk) id() (uint16, uint16) {
1829         return 60, 21
1830 }
1831
1832 func (msg *basicConsumeOk) wait() bool {
1833         return true
1834 }
1835
1836 func (msg *basicConsumeOk) write(w io.Writer) (err error) {
1837
1838         if err = writeShortstr(w, msg.ConsumerTag); err != nil {
1839                 return
1840         }
1841
1842         return
1843 }
1844
1845 func (msg *basicConsumeOk) read(r io.Reader) (err error) {
1846
1847         if msg.ConsumerTag, err = readShortstr(r); err != nil {
1848                 return
1849         }
1850
1851         return
1852 }
1853
1854 type basicCancel struct {
1855         ConsumerTag string
1856         NoWait      bool
1857 }
1858
1859 func (msg *basicCancel) id() (uint16, uint16) {
1860         return 60, 30
1861 }
1862
1863 func (msg *basicCancel) wait() bool {
1864         return true && !msg.NoWait
1865 }
1866
1867 func (msg *basicCancel) write(w io.Writer) (err error) {
1868         var bits byte
1869
1870         if err = writeShortstr(w, msg.ConsumerTag); err != nil {
1871                 return
1872         }
1873
1874         if msg.NoWait {
1875                 bits |= 1 << 0
1876         }
1877
1878         if err = binary.Write(w, binary.BigEndian, bits); err != nil {
1879                 return
1880         }
1881
1882         return
1883 }
1884
1885 func (msg *basicCancel) read(r io.Reader) (err error) {
1886         var bits byte
1887
1888         if msg.ConsumerTag, err = readShortstr(r); err != nil {
1889                 return
1890         }
1891
1892         if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
1893                 return
1894         }
1895         msg.NoWait = (bits&(1<<0) > 0)
1896
1897         return
1898 }
1899
1900 type basicCancelOk struct {
1901         ConsumerTag string
1902 }
1903
1904 func (msg *basicCancelOk) id() (uint16, uint16) {
1905         return 60, 31
1906 }
1907
1908 func (msg *basicCancelOk) wait() bool {
1909         return true
1910 }
1911
1912 func (msg *basicCancelOk) write(w io.Writer) (err error) {
1913
1914         if err = writeShortstr(w, msg.ConsumerTag); err != nil {
1915                 return
1916         }
1917
1918         return
1919 }
1920
1921 func (msg *basicCancelOk) read(r io.Reader) (err error) {
1922
1923         if msg.ConsumerTag, err = readShortstr(r); err != nil {
1924                 return
1925         }
1926
1927         return
1928 }
1929
1930 type basicPublish struct {
1931         reserved1  uint16
1932         Exchange   string
1933         RoutingKey string
1934         Mandatory  bool
1935         Immediate  bool
1936         Properties properties
1937         Body       []byte
1938 }
1939
1940 func (msg *basicPublish) id() (uint16, uint16) {
1941         return 60, 40
1942 }
1943
1944 func (msg *basicPublish) wait() bool {
1945         return false
1946 }
1947
1948 func (msg *basicPublish) getContent() (properties, []byte) {
1949         return msg.Properties, msg.Body
1950 }
1951
1952 func (msg *basicPublish) setContent(props properties, body []byte) {
1953         msg.Properties, msg.Body = props, body
1954 }
1955
1956 func (msg *basicPublish) write(w io.Writer) (err error) {
1957         var bits byte
1958
1959         if err = binary.Write(w, binary.BigEndian, msg.reserved1); err != nil {
1960                 return
1961         }
1962
1963         if err = writeShortstr(w, msg.Exchange); err != nil {
1964                 return
1965         }
1966         if err = writeShortstr(w, msg.RoutingKey); err != nil {
1967                 return
1968         }
1969
1970         if msg.Mandatory {
1971                 bits |= 1 << 0
1972         }
1973
1974         if msg.Immediate {
1975                 bits |= 1 << 1
1976         }
1977
1978         if err = binary.Write(w, binary.BigEndian, bits); err != nil {
1979                 return
1980         }
1981
1982         return
1983 }
1984
1985 func (msg *basicPublish) read(r io.Reader) (err error) {
1986         var bits byte
1987
1988         if err = binary.Read(r, binary.BigEndian, &msg.reserved1); err != nil {
1989                 return
1990         }
1991
1992         if msg.Exchange, err = readShortstr(r); err != nil {
1993                 return
1994         }
1995         if msg.RoutingKey, err = readShortstr(r); err != nil {
1996                 return
1997         }
1998
1999         if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
2000                 return
2001         }
2002         msg.Mandatory = (bits&(1<<0) > 0)
2003         msg.Immediate = (bits&(1<<1) > 0)
2004
2005         return
2006 }
2007
2008 type basicReturn struct {
2009         ReplyCode  uint16
2010         ReplyText  string
2011         Exchange   string
2012         RoutingKey string
2013         Properties properties
2014         Body       []byte
2015 }
2016
2017 func (msg *basicReturn) id() (uint16, uint16) {
2018         return 60, 50
2019 }
2020
2021 func (msg *basicReturn) wait() bool {
2022         return false
2023 }
2024
2025 func (msg *basicReturn) getContent() (properties, []byte) {
2026         return msg.Properties, msg.Body
2027 }
2028
2029 func (msg *basicReturn) setContent(props properties, body []byte) {
2030         msg.Properties, msg.Body = props, body
2031 }
2032
2033 func (msg *basicReturn) write(w io.Writer) (err error) {
2034
2035         if err = binary.Write(w, binary.BigEndian, msg.ReplyCode); err != nil {
2036                 return
2037         }
2038
2039         if err = writeShortstr(w, msg.ReplyText); err != nil {
2040                 return
2041         }
2042         if err = writeShortstr(w, msg.Exchange); err != nil {
2043                 return
2044         }
2045         if err = writeShortstr(w, msg.RoutingKey); err != nil {
2046                 return
2047         }
2048
2049         return
2050 }
2051
2052 func (msg *basicReturn) read(r io.Reader) (err error) {
2053
2054         if err = binary.Read(r, binary.BigEndian, &msg.ReplyCode); err != nil {
2055                 return
2056         }
2057
2058         if msg.ReplyText, err = readShortstr(r); err != nil {
2059                 return
2060         }
2061         if msg.Exchange, err = readShortstr(r); err != nil {
2062                 return
2063         }
2064         if msg.RoutingKey, err = readShortstr(r); err != nil {
2065                 return
2066         }
2067
2068         return
2069 }
2070
2071 type basicDeliver struct {
2072         ConsumerTag string
2073         DeliveryTag uint64
2074         Redelivered bool
2075         Exchange    string
2076         RoutingKey  string
2077         Properties  properties
2078         Body        []byte
2079 }
2080
2081 func (msg *basicDeliver) id() (uint16, uint16) {
2082         return 60, 60
2083 }
2084
2085 func (msg *basicDeliver) wait() bool {
2086         return false
2087 }
2088
2089 func (msg *basicDeliver) getContent() (properties, []byte) {
2090         return msg.Properties, msg.Body
2091 }
2092
2093 func (msg *basicDeliver) setContent(props properties, body []byte) {
2094         msg.Properties, msg.Body = props, body
2095 }
2096
2097 func (msg *basicDeliver) write(w io.Writer) (err error) {
2098         var bits byte
2099
2100         if err = writeShortstr(w, msg.ConsumerTag); err != nil {
2101                 return
2102         }
2103
2104         if err = binary.Write(w, binary.BigEndian, msg.DeliveryTag); err != nil {
2105                 return
2106         }
2107
2108         if msg.Redelivered {
2109                 bits |= 1 << 0
2110         }
2111
2112         if err = binary.Write(w, binary.BigEndian, bits); err != nil {
2113                 return
2114         }
2115
2116         if err = writeShortstr(w, msg.Exchange); err != nil {
2117                 return
2118         }
2119         if err = writeShortstr(w, msg.RoutingKey); err != nil {
2120                 return
2121         }
2122
2123         return
2124 }
2125
2126 func (msg *basicDeliver) read(r io.Reader) (err error) {
2127         var bits byte
2128
2129         if msg.ConsumerTag, err = readShortstr(r); err != nil {
2130                 return
2131         }
2132
2133         if err = binary.Read(r, binary.BigEndian, &msg.DeliveryTag); err != nil {
2134                 return
2135         }
2136
2137         if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
2138                 return
2139         }
2140         msg.Redelivered = (bits&(1<<0) > 0)
2141
2142         if msg.Exchange, err = readShortstr(r); err != nil {
2143                 return
2144         }
2145         if msg.RoutingKey, err = readShortstr(r); err != nil {
2146                 return
2147         }
2148
2149         return
2150 }
2151
2152 type basicGet struct {
2153         reserved1 uint16
2154         Queue     string
2155         NoAck     bool
2156 }
2157
2158 func (msg *basicGet) id() (uint16, uint16) {
2159         return 60, 70
2160 }
2161
2162 func (msg *basicGet) wait() bool {
2163         return true
2164 }
2165
2166 func (msg *basicGet) write(w io.Writer) (err error) {
2167         var bits byte
2168
2169         if err = binary.Write(w, binary.BigEndian, msg.reserved1); err != nil {
2170                 return
2171         }
2172
2173         if err = writeShortstr(w, msg.Queue); err != nil {
2174                 return
2175         }
2176
2177         if msg.NoAck {
2178                 bits |= 1 << 0
2179         }
2180
2181         if err = binary.Write(w, binary.BigEndian, bits); err != nil {
2182                 return
2183         }
2184
2185         return
2186 }
2187
2188 func (msg *basicGet) read(r io.Reader) (err error) {
2189         var bits byte
2190
2191         if err = binary.Read(r, binary.BigEndian, &msg.reserved1); err != nil {
2192                 return
2193         }
2194
2195         if msg.Queue, err = readShortstr(r); err != nil {
2196                 return
2197         }
2198
2199         if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
2200                 return
2201         }
2202         msg.NoAck = (bits&(1<<0) > 0)
2203
2204         return
2205 }
2206
2207 type basicGetOk struct {
2208         DeliveryTag  uint64
2209         Redelivered  bool
2210         Exchange     string
2211         RoutingKey   string
2212         MessageCount uint32
2213         Properties   properties
2214         Body         []byte
2215 }
2216
2217 func (msg *basicGetOk) id() (uint16, uint16) {
2218         return 60, 71
2219 }
2220
2221 func (msg *basicGetOk) wait() bool {
2222         return true
2223 }
2224
2225 func (msg *basicGetOk) getContent() (properties, []byte) {
2226         return msg.Properties, msg.Body
2227 }
2228
2229 func (msg *basicGetOk) setContent(props properties, body []byte) {
2230         msg.Properties, msg.Body = props, body
2231 }
2232
2233 func (msg *basicGetOk) write(w io.Writer) (err error) {
2234         var bits byte
2235
2236         if err = binary.Write(w, binary.BigEndian, msg.DeliveryTag); err != nil {
2237                 return
2238         }
2239
2240         if msg.Redelivered {
2241                 bits |= 1 << 0
2242         }
2243
2244         if err = binary.Write(w, binary.BigEndian, bits); err != nil {
2245                 return
2246         }
2247
2248         if err = writeShortstr(w, msg.Exchange); err != nil {
2249                 return
2250         }
2251         if err = writeShortstr(w, msg.RoutingKey); err != nil {
2252                 return
2253         }
2254
2255         if err = binary.Write(w, binary.BigEndian, msg.MessageCount); err != nil {
2256                 return
2257         }
2258
2259         return
2260 }
2261
2262 func (msg *basicGetOk) read(r io.Reader) (err error) {
2263         var bits byte
2264
2265         if err = binary.Read(r, binary.BigEndian, &msg.DeliveryTag); err != nil {
2266                 return
2267         }
2268
2269         if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
2270                 return
2271         }
2272         msg.Redelivered = (bits&(1<<0) > 0)
2273
2274         if msg.Exchange, err = readShortstr(r); err != nil {
2275                 return
2276         }
2277         if msg.RoutingKey, err = readShortstr(r); err != nil {
2278                 return
2279         }
2280
2281         if err = binary.Read(r, binary.BigEndian, &msg.MessageCount); err != nil {
2282                 return
2283         }
2284
2285         return
2286 }
2287
2288 type basicGetEmpty struct {
2289         reserved1 string
2290 }
2291
2292 func (msg *basicGetEmpty) id() (uint16, uint16) {
2293         return 60, 72
2294 }
2295
2296 func (msg *basicGetEmpty) wait() bool {
2297         return true
2298 }
2299
2300 func (msg *basicGetEmpty) write(w io.Writer) (err error) {
2301
2302         if err = writeShortstr(w, msg.reserved1); err != nil {
2303                 return
2304         }
2305
2306         return
2307 }
2308
2309 func (msg *basicGetEmpty) read(r io.Reader) (err error) {
2310
2311         if msg.reserved1, err = readShortstr(r); err != nil {
2312                 return
2313         }
2314
2315         return
2316 }
2317
2318 type basicAck struct {
2319         DeliveryTag uint64
2320         Multiple    bool
2321 }
2322
2323 func (msg *basicAck) id() (uint16, uint16) {
2324         return 60, 80
2325 }
2326
2327 func (msg *basicAck) wait() bool {
2328         return false
2329 }
2330
2331 func (msg *basicAck) write(w io.Writer) (err error) {
2332         var bits byte
2333
2334         if err = binary.Write(w, binary.BigEndian, msg.DeliveryTag); err != nil {
2335                 return
2336         }
2337
2338         if msg.Multiple {
2339                 bits |= 1 << 0
2340         }
2341
2342         if err = binary.Write(w, binary.BigEndian, bits); err != nil {
2343                 return
2344         }
2345
2346         return
2347 }
2348
2349 func (msg *basicAck) read(r io.Reader) (err error) {
2350         var bits byte
2351
2352         if err = binary.Read(r, binary.BigEndian, &msg.DeliveryTag); err != nil {
2353                 return
2354         }
2355
2356         if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
2357                 return
2358         }
2359         msg.Multiple = (bits&(1<<0) > 0)
2360
2361         return
2362 }
2363
2364 type basicReject struct {
2365         DeliveryTag uint64
2366         Requeue     bool
2367 }
2368
2369 func (msg *basicReject) id() (uint16, uint16) {
2370         return 60, 90
2371 }
2372
2373 func (msg *basicReject) wait() bool {
2374         return false
2375 }
2376
2377 func (msg *basicReject) write(w io.Writer) (err error) {
2378         var bits byte
2379
2380         if err = binary.Write(w, binary.BigEndian, msg.DeliveryTag); err != nil {
2381                 return
2382         }
2383
2384         if msg.Requeue {
2385                 bits |= 1 << 0
2386         }
2387
2388         if err = binary.Write(w, binary.BigEndian, bits); err != nil {
2389                 return
2390         }
2391
2392         return
2393 }
2394
2395 func (msg *basicReject) read(r io.Reader) (err error) {
2396         var bits byte
2397
2398         if err = binary.Read(r, binary.BigEndian, &msg.DeliveryTag); err != nil {
2399                 return
2400         }
2401
2402         if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
2403                 return
2404         }
2405         msg.Requeue = (bits&(1<<0) > 0)
2406
2407         return
2408 }
2409
2410 type basicRecoverAsync struct {
2411         Requeue bool
2412 }
2413
2414 func (msg *basicRecoverAsync) id() (uint16, uint16) {
2415         return 60, 100
2416 }
2417
2418 func (msg *basicRecoverAsync) wait() bool {
2419         return false
2420 }
2421
2422 func (msg *basicRecoverAsync) write(w io.Writer) (err error) {
2423         var bits byte
2424
2425         if msg.Requeue {
2426                 bits |= 1 << 0
2427         }
2428
2429         if err = binary.Write(w, binary.BigEndian, bits); err != nil {
2430                 return
2431         }
2432
2433         return
2434 }
2435
2436 func (msg *basicRecoverAsync) read(r io.Reader) (err error) {
2437         var bits byte
2438
2439         if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
2440                 return
2441         }
2442         msg.Requeue = (bits&(1<<0) > 0)
2443
2444         return
2445 }
2446
2447 type basicRecover struct {
2448         Requeue bool
2449 }
2450
2451 func (msg *basicRecover) id() (uint16, uint16) {
2452         return 60, 110
2453 }
2454
2455 func (msg *basicRecover) wait() bool {
2456         return true
2457 }
2458
2459 func (msg *basicRecover) write(w io.Writer) (err error) {
2460         var bits byte
2461
2462         if msg.Requeue {
2463                 bits |= 1 << 0
2464         }
2465
2466         if err = binary.Write(w, binary.BigEndian, bits); err != nil {
2467                 return
2468         }
2469
2470         return
2471 }
2472
2473 func (msg *basicRecover) read(r io.Reader) (err error) {
2474         var bits byte
2475
2476         if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
2477                 return
2478         }
2479         msg.Requeue = (bits&(1<<0) > 0)
2480
2481         return
2482 }
2483
2484 type basicRecoverOk struct {
2485 }
2486
2487 func (msg *basicRecoverOk) id() (uint16, uint16) {
2488         return 60, 111
2489 }
2490
2491 func (msg *basicRecoverOk) wait() bool {
2492         return true
2493 }
2494
2495 func (msg *basicRecoverOk) write(w io.Writer) (err error) {
2496
2497         return
2498 }
2499
2500 func (msg *basicRecoverOk) read(r io.Reader) (err error) {
2501
2502         return
2503 }
2504
2505 type basicNack struct {
2506         DeliveryTag uint64
2507         Multiple    bool
2508         Requeue     bool
2509 }
2510
2511 func (msg *basicNack) id() (uint16, uint16) {
2512         return 60, 120
2513 }
2514
2515 func (msg *basicNack) wait() bool {
2516         return false
2517 }
2518
2519 func (msg *basicNack) write(w io.Writer) (err error) {
2520         var bits byte
2521
2522         if err = binary.Write(w, binary.BigEndian, msg.DeliveryTag); err != nil {
2523                 return
2524         }
2525
2526         if msg.Multiple {
2527                 bits |= 1 << 0
2528         }
2529
2530         if msg.Requeue {
2531                 bits |= 1 << 1
2532         }
2533
2534         if err = binary.Write(w, binary.BigEndian, bits); err != nil {
2535                 return
2536         }
2537
2538         return
2539 }
2540
2541 func (msg *basicNack) read(r io.Reader) (err error) {
2542         var bits byte
2543
2544         if err = binary.Read(r, binary.BigEndian, &msg.DeliveryTag); err != nil {
2545                 return
2546         }
2547
2548         if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
2549                 return
2550         }
2551         msg.Multiple = (bits&(1<<0) > 0)
2552         msg.Requeue = (bits&(1<<1) > 0)
2553
2554         return
2555 }
2556
2557 type txSelect struct {
2558 }
2559
2560 func (msg *txSelect) id() (uint16, uint16) {
2561         return 90, 10
2562 }
2563
2564 func (msg *txSelect) wait() bool {
2565         return true
2566 }
2567
2568 func (msg *txSelect) write(w io.Writer) (err error) {
2569
2570         return
2571 }
2572
2573 func (msg *txSelect) read(r io.Reader) (err error) {
2574
2575         return
2576 }
2577
2578 type txSelectOk struct {
2579 }
2580
2581 func (msg *txSelectOk) id() (uint16, uint16) {
2582         return 90, 11
2583 }
2584
2585 func (msg *txSelectOk) wait() bool {
2586         return true
2587 }
2588
2589 func (msg *txSelectOk) write(w io.Writer) (err error) {
2590
2591         return
2592 }
2593
2594 func (msg *txSelectOk) read(r io.Reader) (err error) {
2595
2596         return
2597 }
2598
2599 type txCommit struct {
2600 }
2601
2602 func (msg *txCommit) id() (uint16, uint16) {
2603         return 90, 20
2604 }
2605
2606 func (msg *txCommit) wait() bool {
2607         return true
2608 }
2609
2610 func (msg *txCommit) write(w io.Writer) (err error) {
2611
2612         return
2613 }
2614
2615 func (msg *txCommit) read(r io.Reader) (err error) {
2616
2617         return
2618 }
2619
2620 type txCommitOk struct {
2621 }
2622
2623 func (msg *txCommitOk) id() (uint16, uint16) {
2624         return 90, 21
2625 }
2626
2627 func (msg *txCommitOk) wait() bool {
2628         return true
2629 }
2630
2631 func (msg *txCommitOk) write(w io.Writer) (err error) {
2632
2633         return
2634 }
2635
2636 func (msg *txCommitOk) read(r io.Reader) (err error) {
2637
2638         return
2639 }
2640
2641 type txRollback struct {
2642 }
2643
2644 func (msg *txRollback) id() (uint16, uint16) {
2645         return 90, 30
2646 }
2647
2648 func (msg *txRollback) wait() bool {
2649         return true
2650 }
2651
2652 func (msg *txRollback) write(w io.Writer) (err error) {
2653
2654         return
2655 }
2656
2657 func (msg *txRollback) read(r io.Reader) (err error) {
2658
2659         return
2660 }
2661
2662 type txRollbackOk struct {
2663 }
2664
2665 func (msg *txRollbackOk) id() (uint16, uint16) {
2666         return 90, 31
2667 }
2668
2669 func (msg *txRollbackOk) wait() bool {
2670         return true
2671 }
2672
2673 func (msg *txRollbackOk) write(w io.Writer) (err error) {
2674
2675         return
2676 }
2677
2678 func (msg *txRollbackOk) read(r io.Reader) (err error) {
2679
2680         return
2681 }
2682
2683 type confirmSelect struct {
2684         Nowait bool
2685 }
2686
2687 func (msg *confirmSelect) id() (uint16, uint16) {
2688         return 85, 10
2689 }
2690
2691 func (msg *confirmSelect) wait() bool {
2692         return true
2693 }
2694
2695 func (msg *confirmSelect) write(w io.Writer) (err error) {
2696         var bits byte
2697
2698         if msg.Nowait {
2699                 bits |= 1 << 0
2700         }
2701
2702         if err = binary.Write(w, binary.BigEndian, bits); err != nil {
2703                 return
2704         }
2705
2706         return
2707 }
2708
2709 func (msg *confirmSelect) read(r io.Reader) (err error) {
2710         var bits byte
2711
2712         if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
2713                 return
2714         }
2715         msg.Nowait = (bits&(1<<0) > 0)
2716
2717         return
2718 }
2719
2720 type confirmSelectOk struct {
2721 }
2722
2723 func (msg *confirmSelectOk) id() (uint16, uint16) {
2724         return 85, 11
2725 }
2726
2727 func (msg *confirmSelectOk) wait() bool {
2728         return true
2729 }
2730
2731 func (msg *confirmSelectOk) write(w io.Writer) (err error) {
2732
2733         return
2734 }
2735
2736 func (msg *confirmSelectOk) read(r io.Reader) (err error) {
2737
2738         return
2739 }
2740
2741 func (r *reader) parseMethodFrame(channel uint16, size uint32) (f frame, err error) {
2742         mf := &methodFrame{
2743                 ChannelId: channel,
2744         }
2745
2746         if err = binary.Read(r.r, binary.BigEndian, &mf.ClassId); err != nil {
2747                 return
2748         }
2749
2750         if err = binary.Read(r.r, binary.BigEndian, &mf.MethodId); err != nil {
2751                 return
2752         }
2753
2754         switch mf.ClassId {
2755
2756         case 10: // connection
2757                 switch mf.MethodId {
2758
2759                 case 10: // connection start
2760                         //fmt.Println("NextMethod: class:10 method:10")
2761                         method := &connectionStart{}
2762                         if err = method.read(r.r); err != nil {
2763                                 return
2764                         }
2765                         mf.Method = method
2766
2767                 case 11: // connection start-ok
2768                         //fmt.Println("NextMethod: class:10 method:11")
2769                         method := &connectionStartOk{}
2770                         if err = method.read(r.r); err != nil {
2771                                 return
2772                         }
2773                         mf.Method = method
2774
2775                 case 20: // connection secure
2776                         //fmt.Println("NextMethod: class:10 method:20")
2777                         method := &connectionSecure{}
2778                         if err = method.read(r.r); err != nil {
2779                                 return
2780                         }
2781                         mf.Method = method
2782
2783                 case 21: // connection secure-ok
2784                         //fmt.Println("NextMethod: class:10 method:21")
2785                         method := &connectionSecureOk{}
2786                         if err = method.read(r.r); err != nil {
2787                                 return
2788                         }
2789                         mf.Method = method
2790
2791                 case 30: // connection tune
2792                         //fmt.Println("NextMethod: class:10 method:30")
2793                         method := &connectionTune{}
2794                         if err = method.read(r.r); err != nil {
2795                                 return
2796                         }
2797                         mf.Method = method
2798
2799                 case 31: // connection tune-ok
2800                         //fmt.Println("NextMethod: class:10 method:31")
2801                         method := &connectionTuneOk{}
2802                         if err = method.read(r.r); err != nil {
2803                                 return
2804                         }
2805                         mf.Method = method
2806
2807                 case 40: // connection open
2808                         //fmt.Println("NextMethod: class:10 method:40")
2809                         method := &connectionOpen{}
2810                         if err = method.read(r.r); err != nil {
2811                                 return
2812                         }
2813                         mf.Method = method
2814
2815                 case 41: // connection open-ok
2816                         //fmt.Println("NextMethod: class:10 method:41")
2817                         method := &connectionOpenOk{}
2818                         if err = method.read(r.r); err != nil {
2819                                 return
2820                         }
2821                         mf.Method = method
2822
2823                 case 50: // connection close
2824                         //fmt.Println("NextMethod: class:10 method:50")
2825                         method := &connectionClose{}
2826                         if err = method.read(r.r); err != nil {
2827                                 return
2828                         }
2829                         mf.Method = method
2830
2831                 case 51: // connection close-ok
2832                         //fmt.Println("NextMethod: class:10 method:51")
2833                         method := &connectionCloseOk{}
2834                         if err = method.read(r.r); err != nil {
2835                                 return
2836                         }
2837                         mf.Method = method
2838
2839                 case 60: // connection blocked
2840                         //fmt.Println("NextMethod: class:10 method:60")
2841                         method := &connectionBlocked{}
2842                         if err = method.read(r.r); err != nil {
2843                                 return
2844                         }
2845                         mf.Method = method
2846
2847                 case 61: // connection unblocked
2848                         //fmt.Println("NextMethod: class:10 method:61")
2849                         method := &connectionUnblocked{}
2850                         if err = method.read(r.r); err != nil {
2851                                 return
2852                         }
2853                         mf.Method = method
2854
2855                 default:
2856                         return nil, fmt.Errorf("Bad method frame, unknown method %d for class %d", mf.MethodId, mf.ClassId)
2857                 }
2858
2859         case 20: // channel
2860                 switch mf.MethodId {
2861
2862                 case 10: // channel open
2863                         //fmt.Println("NextMethod: class:20 method:10")
2864                         method := &channelOpen{}
2865                         if err = method.read(r.r); err != nil {
2866                                 return
2867                         }
2868                         mf.Method = method
2869
2870                 case 11: // channel open-ok
2871                         //fmt.Println("NextMethod: class:20 method:11")
2872                         method := &channelOpenOk{}
2873                         if err = method.read(r.r); err != nil {
2874                                 return
2875                         }
2876                         mf.Method = method
2877
2878                 case 20: // channel flow
2879                         //fmt.Println("NextMethod: class:20 method:20")
2880                         method := &channelFlow{}
2881                         if err = method.read(r.r); err != nil {
2882                                 return
2883                         }
2884                         mf.Method = method
2885
2886                 case 21: // channel flow-ok
2887                         //fmt.Println("NextMethod: class:20 method:21")
2888                         method := &channelFlowOk{}
2889                         if err = method.read(r.r); err != nil {
2890                                 return
2891                         }
2892                         mf.Method = method
2893
2894                 case 40: // channel close
2895                         //fmt.Println("NextMethod: class:20 method:40")
2896                         method := &channelClose{}
2897                         if err = method.read(r.r); err != nil {
2898                                 return
2899                         }
2900                         mf.Method = method
2901
2902                 case 41: // channel close-ok
2903                         //fmt.Println("NextMethod: class:20 method:41")
2904                         method := &channelCloseOk{}
2905                         if err = method.read(r.r); err != nil {
2906                                 return
2907                         }
2908                         mf.Method = method
2909
2910                 default:
2911                         return nil, fmt.Errorf("Bad method frame, unknown method %d for class %d", mf.MethodId, mf.ClassId)
2912                 }
2913
2914         case 40: // exchange
2915                 switch mf.MethodId {
2916
2917                 case 10: // exchange declare
2918                         //fmt.Println("NextMethod: class:40 method:10")
2919                         method := &exchangeDeclare{}
2920                         if err = method.read(r.r); err != nil {
2921                                 return
2922                         }
2923                         mf.Method = method
2924
2925                 case 11: // exchange declare-ok
2926                         //fmt.Println("NextMethod: class:40 method:11")
2927                         method := &exchangeDeclareOk{}
2928                         if err = method.read(r.r); err != nil {
2929                                 return
2930                         }
2931                         mf.Method = method
2932
2933                 case 20: // exchange delete
2934                         //fmt.Println("NextMethod: class:40 method:20")
2935                         method := &exchangeDelete{}
2936                         if err = method.read(r.r); err != nil {
2937                                 return
2938                         }
2939                         mf.Method = method
2940
2941                 case 21: // exchange delete-ok
2942                         //fmt.Println("NextMethod: class:40 method:21")
2943                         method := &exchangeDeleteOk{}
2944                         if err = method.read(r.r); err != nil {
2945                                 return
2946                         }
2947                         mf.Method = method
2948
2949                 case 30: // exchange bind
2950                         //fmt.Println("NextMethod: class:40 method:30")
2951                         method := &exchangeBind{}
2952                         if err = method.read(r.r); err != nil {
2953                                 return
2954                         }
2955                         mf.Method = method
2956
2957                 case 31: // exchange bind-ok
2958                         //fmt.Println("NextMethod: class:40 method:31")
2959                         method := &exchangeBindOk{}
2960                         if err = method.read(r.r); err != nil {
2961                                 return
2962                         }
2963                         mf.Method = method
2964
2965                 case 40: // exchange unbind
2966                         //fmt.Println("NextMethod: class:40 method:40")
2967                         method := &exchangeUnbind{}
2968                         if err = method.read(r.r); err != nil {
2969                                 return
2970                         }
2971                         mf.Method = method
2972
2973                 case 51: // exchange unbind-ok
2974                         //fmt.Println("NextMethod: class:40 method:51")
2975                         method := &exchangeUnbindOk{}
2976                         if err = method.read(r.r); err != nil {
2977                                 return
2978                         }
2979                         mf.Method = method
2980
2981                 default:
2982                         return nil, fmt.Errorf("Bad method frame, unknown method %d for class %d", mf.MethodId, mf.ClassId)
2983                 }
2984
2985         case 50: // queue
2986                 switch mf.MethodId {
2987
2988                 case 10: // queue declare
2989                         //fmt.Println("NextMethod: class:50 method:10")
2990                         method := &queueDeclare{}
2991                         if err = method.read(r.r); err != nil {
2992                                 return
2993                         }
2994                         mf.Method = method
2995
2996                 case 11: // queue declare-ok
2997                         //fmt.Println("NextMethod: class:50 method:11")
2998                         method := &queueDeclareOk{}
2999                         if err = method.read(r.r); err != nil {
3000                                 return
3001                         }
3002                         mf.Method = method
3003
3004                 case 20: // queue bind
3005                         //fmt.Println("NextMethod: class:50 method:20")
3006                         method := &queueBind{}
3007                         if err = method.read(r.r); err != nil {
3008                                 return
3009                         }
3010                         mf.Method = method
3011
3012                 case 21: // queue bind-ok
3013                         //fmt.Println("NextMethod: class:50 method:21")
3014                         method := &queueBindOk{}
3015                         if err = method.read(r.r); err != nil {
3016                                 return
3017                         }
3018                         mf.Method = method
3019
3020                 case 50: // queue unbind
3021                         //fmt.Println("NextMethod: class:50 method:50")
3022                         method := &queueUnbind{}
3023                         if err = method.read(r.r); err != nil {
3024                                 return
3025                         }
3026                         mf.Method = method
3027
3028                 case 51: // queue unbind-ok
3029                         //fmt.Println("NextMethod: class:50 method:51")
3030                         method := &queueUnbindOk{}
3031                         if err = method.read(r.r); err != nil {
3032                                 return
3033                         }
3034                         mf.Method = method
3035
3036                 case 30: // queue purge
3037                         //fmt.Println("NextMethod: class:50 method:30")
3038                         method := &queuePurge{}
3039                         if err = method.read(r.r); err != nil {
3040                                 return
3041                         }
3042                         mf.Method = method
3043
3044                 case 31: // queue purge-ok
3045                         //fmt.Println("NextMethod: class:50 method:31")
3046                         method := &queuePurgeOk{}
3047                         if err = method.read(r.r); err != nil {
3048                                 return
3049                         }
3050                         mf.Method = method
3051
3052                 case 40: // queue delete
3053                         //fmt.Println("NextMethod: class:50 method:40")
3054                         method := &queueDelete{}
3055                         if err = method.read(r.r); err != nil {
3056                                 return
3057                         }
3058                         mf.Method = method
3059
3060                 case 41: // queue delete-ok
3061                         //fmt.Println("NextMethod: class:50 method:41")
3062                         method := &queueDeleteOk{}
3063                         if err = method.read(r.r); err != nil {
3064                                 return
3065                         }
3066                         mf.Method = method
3067
3068                 default:
3069                         return nil, fmt.Errorf("Bad method frame, unknown method %d for class %d", mf.MethodId, mf.ClassId)
3070                 }
3071
3072         case 60: // basic
3073                 switch mf.MethodId {
3074
3075                 case 10: // basic qos
3076                         //fmt.Println("NextMethod: class:60 method:10")
3077                         method := &basicQos{}
3078                         if err = method.read(r.r); err != nil {
3079                                 return
3080                         }
3081                         mf.Method = method
3082
3083                 case 11: // basic qos-ok
3084                         //fmt.Println("NextMethod: class:60 method:11")
3085                         method := &basicQosOk{}
3086                         if err = method.read(r.r); err != nil {
3087                                 return
3088                         }
3089                         mf.Method = method
3090
3091                 case 20: // basic consume
3092                         //fmt.Println("NextMethod: class:60 method:20")
3093                         method := &basicConsume{}
3094                         if err = method.read(r.r); err != nil {
3095                                 return
3096                         }
3097                         mf.Method = method
3098
3099                 case 21: // basic consume-ok
3100                         //fmt.Println("NextMethod: class:60 method:21")
3101                         method := &basicConsumeOk{}
3102                         if err = method.read(r.r); err != nil {
3103                                 return
3104                         }
3105                         mf.Method = method
3106
3107                 case 30: // basic cancel
3108                         //fmt.Println("NextMethod: class:60 method:30")
3109                         method := &basicCancel{}
3110                         if err = method.read(r.r); err != nil {
3111                                 return
3112                         }
3113                         mf.Method = method
3114
3115                 case 31: // basic cancel-ok
3116                         //fmt.Println("NextMethod: class:60 method:31")
3117                         method := &basicCancelOk{}
3118                         if err = method.read(r.r); err != nil {
3119                                 return
3120                         }
3121                         mf.Method = method
3122
3123                 case 40: // basic publish
3124                         //fmt.Println("NextMethod: class:60 method:40")
3125                         method := &basicPublish{}
3126                         if err = method.read(r.r); err != nil {
3127                                 return
3128                         }
3129                         mf.Method = method
3130
3131                 case 50: // basic return
3132                         //fmt.Println("NextMethod: class:60 method:50")
3133                         method := &basicReturn{}
3134                         if err = method.read(r.r); err != nil {
3135                                 return
3136                         }
3137                         mf.Method = method
3138
3139                 case 60: // basic deliver
3140                         //fmt.Println("NextMethod: class:60 method:60")
3141                         method := &basicDeliver{}
3142                         if err = method.read(r.r); err != nil {
3143                                 return
3144                         }
3145                         mf.Method = method
3146
3147                 case 70: // basic get
3148                         //fmt.Println("NextMethod: class:60 method:70")
3149                         method := &basicGet{}
3150                         if err = method.read(r.r); err != nil {
3151                                 return
3152                         }
3153                         mf.Method = method
3154
3155                 case 71: // basic get-ok
3156                         //fmt.Println("NextMethod: class:60 method:71")
3157                         method := &basicGetOk{}
3158                         if err = method.read(r.r); err != nil {
3159                                 return
3160                         }
3161                         mf.Method = method
3162
3163                 case 72: // basic get-empty
3164                         //fmt.Println("NextMethod: class:60 method:72")
3165                         method := &basicGetEmpty{}
3166                         if err = method.read(r.r); err != nil {
3167                                 return
3168                         }
3169                         mf.Method = method
3170
3171                 case 80: // basic ack
3172                         //fmt.Println("NextMethod: class:60 method:80")
3173                         method := &basicAck{}
3174                         if err = method.read(r.r); err != nil {
3175                                 return
3176                         }
3177                         mf.Method = method
3178
3179                 case 90: // basic reject
3180                         //fmt.Println("NextMethod: class:60 method:90")
3181                         method := &basicReject{}
3182                         if err = method.read(r.r); err != nil {
3183                                 return
3184                         }
3185                         mf.Method = method
3186
3187                 case 100: // basic recover-async
3188                         //fmt.Println("NextMethod: class:60 method:100")
3189                         method := &basicRecoverAsync{}
3190                         if err = method.read(r.r); err != nil {
3191                                 return
3192                         }
3193                         mf.Method = method
3194
3195                 case 110: // basic recover
3196                         //fmt.Println("NextMethod: class:60 method:110")
3197                         method := &basicRecover{}
3198                         if err = method.read(r.r); err != nil {
3199                                 return
3200                         }
3201                         mf.Method = method
3202
3203                 case 111: // basic recover-ok
3204                         //fmt.Println("NextMethod: class:60 method:111")
3205                         method := &basicRecoverOk{}
3206                         if err = method.read(r.r); err != nil {
3207                                 return
3208                         }
3209                         mf.Method = method
3210
3211                 case 120: // basic nack
3212                         //fmt.Println("NextMethod: class:60 method:120")
3213                         method := &basicNack{}
3214                         if err = method.read(r.r); err != nil {
3215                                 return
3216                         }
3217                         mf.Method = method
3218
3219                 default:
3220                         return nil, fmt.Errorf("Bad method frame, unknown method %d for class %d", mf.MethodId, mf.ClassId)
3221                 }
3222
3223         case 90: // tx
3224                 switch mf.MethodId {
3225
3226                 case 10: // tx select
3227                         //fmt.Println("NextMethod: class:90 method:10")
3228                         method := &txSelect{}
3229                         if err = method.read(r.r); err != nil {
3230                                 return
3231                         }
3232                         mf.Method = method
3233
3234                 case 11: // tx select-ok
3235                         //fmt.Println("NextMethod: class:90 method:11")
3236                         method := &txSelectOk{}
3237                         if err = method.read(r.r); err != nil {
3238                                 return
3239                         }
3240                         mf.Method = method
3241
3242                 case 20: // tx commit
3243                         //fmt.Println("NextMethod: class:90 method:20")
3244                         method := &txCommit{}
3245                         if err = method.read(r.r); err != nil {
3246                                 return
3247                         }
3248                         mf.Method = method
3249
3250                 case 21: // tx commit-ok
3251                         //fmt.Println("NextMethod: class:90 method:21")
3252                         method := &txCommitOk{}
3253                         if err = method.read(r.r); err != nil {
3254                                 return
3255                         }
3256                         mf.Method = method
3257
3258                 case 30: // tx rollback
3259                         //fmt.Println("NextMethod: class:90 method:30")
3260                         method := &txRollback{}
3261                         if err = method.read(r.r); err != nil {
3262                                 return
3263                         }
3264                         mf.Method = method
3265
3266                 case 31: // tx rollback-ok
3267                         //fmt.Println("NextMethod: class:90 method:31")
3268                         method := &txRollbackOk{}
3269                         if err = method.read(r.r); err != nil {
3270                                 return
3271                         }
3272                         mf.Method = method
3273
3274                 default:
3275                         return nil, fmt.Errorf("Bad method frame, unknown method %d for class %d", mf.MethodId, mf.ClassId)
3276                 }
3277
3278         case 85: // confirm
3279                 switch mf.MethodId {
3280
3281                 case 10: // confirm select
3282                         //fmt.Println("NextMethod: class:85 method:10")
3283                         method := &confirmSelect{}
3284                         if err = method.read(r.r); err != nil {
3285                                 return
3286                         }
3287                         mf.Method = method
3288
3289                 case 11: // confirm select-ok
3290                         //fmt.Println("NextMethod: class:85 method:11")
3291                         method := &confirmSelectOk{}
3292                         if err = method.read(r.r); err != nil {
3293                                 return
3294                         }
3295                         mf.Method = method
3296
3297                 default:
3298                         return nil, fmt.Errorf("Bad method frame, unknown method %d for class %d", mf.MethodId, mf.ClassId)
3299                 }
3300
3301         default:
3302                 return nil, fmt.Errorf("Bad method frame, unknown class %d", mf.ClassId)
3303         }
3304
3305         return mf, nil
3306 }