amq_protocol/
generated.rs

1/// Protocol metadata
2pub mod metadata {
3    use super::*;
4
5    /// The name of the protocol
6    pub const NAME: &str = "AMQP";
7    /// The major version of the protocol
8    pub const MAJOR_VERSION: ShortShortUInt = 0;
9    /// The minor version of the protocol
10    pub const MINOR_VERSION: ShortShortUInt = 9;
11    /// The revision (version) of the protocol
12    pub const REVISION: ShortShortUInt = 1;
13    /// The default port of the protocol
14    pub const PORT: LongUInt = 5672;
15    /// The copyright holding the protocol
16    pub const COPYRIGHT: &str = r#"Copyright (C) 2007-2024 Broadcom Inc. and its subsidiaries. All rights reserved.
17
18Permission is hereby granted, free of charge, to any person
19obtaining a copy of this file (the "Software"), to deal in the
20Software without restriction, including without limitation the 
21rights to use, copy, modify, merge, publish, distribute, 
22sublicense, and/or sell copies of the Software, and to permit 
23persons to whom the Software is furnished to do so, subject to 
24the following conditions:
25
26The above copyright notice and this permission notice shall be
27included in all copies or substantial portions of the Software.
28
29THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
30EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
31OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
32NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
33HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
34WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
35FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
36OTHER DEALINGS IN THE SOFTWARE.
37
38Class information entered from amqp_xml0-8.pdf and domain types from amqp-xml-doc0-9.pdf
39Updated for 0-9-1 by Tony Garnock-Jones
40
41b3cb053f15e7b98808c0ccc67f23cb3e  amqp_xml0-8.pdf
42http://twiststandards.org/?option=com_docman&task=cat_view&gid=28&Itemid=90
438444db91e2949dbecfb2585e9eef6d64  amqp-xml-doc0-9.pdf
44https://jira.amqp.org/confluence/download/attachments/720900/amqp-xml-doc0-9.pdf?version=1
45"#;
46}
47
48/// Protocol constants
49pub mod constants {
50    use super::*;
51
52    /// FRAME-METHOD (Generated)
53    pub const FRAME_METHOD: ShortShortUInt = 1;
54    /// FRAME-HEADER (Generated)
55    pub const FRAME_HEADER: ShortShortUInt = 2;
56    /// FRAME-BODY (Generated)
57    pub const FRAME_BODY: ShortShortUInt = 3;
58    /// FRAME-HEARTBEAT (Generated)
59    pub const FRAME_HEARTBEAT: ShortShortUInt = 8;
60    /// FRAME-MIN-SIZE (Generated)
61    pub const FRAME_MIN_SIZE: LongUInt = 8192;
62    /// FRAME-END (Generated)
63    pub const FRAME_END: ShortShortUInt = 206;
64    /// REPLY-SUCCESS (Generated)
65    pub const REPLY_SUCCESS: ShortUInt = 200;
66}
67
68/// The available soft AMQP errors
69#[derive(Clone, Debug, PartialEq)]
70pub enum AMQPSoftError {
71    /// CONTENT-TOO-LARGE (Generated)
72    CONTENTTOOLARGE,
73    /// NO-ROUTE (Generated)
74    NOROUTE,
75    /// NO-CONSUMERS (Generated)
76    NOCONSUMERS,
77    /// ACCESS-REFUSED (Generated)
78    ACCESSREFUSED,
79    /// NOT-FOUND (Generated)
80    NOTFOUND,
81    /// RESOURCE-LOCKED (Generated)
82    RESOURCELOCKED,
83    /// PRECONDITION-FAILED (Generated)
84    PRECONDITIONFAILED,
85}
86
87impl AMQPSoftError {
88    /// Get the id of the soft error
89    pub fn get_id(&self) -> Identifier {
90        match *self {
91            AMQPSoftError::CONTENTTOOLARGE => 311,
92            AMQPSoftError::NOROUTE => 312,
93            AMQPSoftError::NOCONSUMERS => 313,
94            AMQPSoftError::ACCESSREFUSED => 403,
95            AMQPSoftError::NOTFOUND => 404,
96            AMQPSoftError::RESOURCELOCKED => 405,
97            AMQPSoftError::PRECONDITIONFAILED => 406,
98        }
99    }
100
101    /// Get the soft error corresponding to an id
102    pub fn from_id(id: Identifier) -> Option<AMQPSoftError> {
103        match id {
104            311 => Some(AMQPSoftError::CONTENTTOOLARGE),
105            312 => Some(AMQPSoftError::NOROUTE),
106            313 => Some(AMQPSoftError::NOCONSUMERS),
107            403 => Some(AMQPSoftError::ACCESSREFUSED),
108            404 => Some(AMQPSoftError::NOTFOUND),
109            405 => Some(AMQPSoftError::RESOURCELOCKED),
110            406 => Some(AMQPSoftError::PRECONDITIONFAILED),
111            _ => None,
112        }
113    }
114}
115
116impl fmt::Display for AMQPSoftError {
117    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
118        match self {
119            AMQPSoftError::CONTENTTOOLARGE => write!(f, "CONTENT-TOO-LARGE"),
120            AMQPSoftError::NOROUTE => write!(f, "NO-ROUTE"),
121            AMQPSoftError::NOCONSUMERS => write!(f, "NO-CONSUMERS"),
122            AMQPSoftError::ACCESSREFUSED => write!(f, "ACCESS-REFUSED"),
123            AMQPSoftError::NOTFOUND => write!(f, "NOT-FOUND"),
124            AMQPSoftError::RESOURCELOCKED => write!(f, "RESOURCE-LOCKED"),
125            AMQPSoftError::PRECONDITIONFAILED => write!(f, "PRECONDITION-FAILED"),
126        }
127    }
128}
129
130/// The available hard AMQP errors
131#[derive(Clone, Debug, PartialEq)]
132pub enum AMQPHardError {
133    /// CONNECTION-FORCED (Generated)
134    CONNECTIONFORCED,
135    /// INVALID-PATH (Generated)
136    INVALIDPATH,
137    /// FRAME-ERROR (Generated)
138    FRAMEERROR,
139    /// SYNTAX-ERROR (Generated)
140    SYNTAXERROR,
141    /// COMMAND-INVALID (Generated)
142    COMMANDINVALID,
143    /// CHANNEL-ERROR (Generated)
144    CHANNELERROR,
145    /// UNEXPECTED-FRAME (Generated)
146    UNEXPECTEDFRAME,
147    /// RESOURCE-ERROR (Generated)
148    RESOURCEERROR,
149    /// NOT-ALLOWED (Generated)
150    NOTALLOWED,
151    /// NOT-IMPLEMENTED (Generated)
152    NOTIMPLEMENTED,
153    /// INTERNAL-ERROR (Generated)
154    INTERNALERROR,
155}
156
157impl AMQPHardError {
158    /// Get the id of the hard error
159    pub fn get_id(&self) -> Identifier {
160        match *self {
161            AMQPHardError::CONNECTIONFORCED => 320,
162            AMQPHardError::INVALIDPATH => 402,
163            AMQPHardError::FRAMEERROR => 501,
164            AMQPHardError::SYNTAXERROR => 502,
165            AMQPHardError::COMMANDINVALID => 503,
166            AMQPHardError::CHANNELERROR => 504,
167            AMQPHardError::UNEXPECTEDFRAME => 505,
168            AMQPHardError::RESOURCEERROR => 506,
169            AMQPHardError::NOTALLOWED => 530,
170            AMQPHardError::NOTIMPLEMENTED => 540,
171            AMQPHardError::INTERNALERROR => 541,
172        }
173    }
174
175    /// Get the hard error corresponding to an id
176    pub fn from_id(id: Identifier) -> Option<AMQPHardError> {
177        match id {
178            320 => Some(AMQPHardError::CONNECTIONFORCED),
179            402 => Some(AMQPHardError::INVALIDPATH),
180            501 => Some(AMQPHardError::FRAMEERROR),
181            502 => Some(AMQPHardError::SYNTAXERROR),
182            503 => Some(AMQPHardError::COMMANDINVALID),
183            504 => Some(AMQPHardError::CHANNELERROR),
184            505 => Some(AMQPHardError::UNEXPECTEDFRAME),
185            506 => Some(AMQPHardError::RESOURCEERROR),
186            530 => Some(AMQPHardError::NOTALLOWED),
187            540 => Some(AMQPHardError::NOTIMPLEMENTED),
188            541 => Some(AMQPHardError::INTERNALERROR),
189            _ => None,
190        }
191    }
192}
193
194impl fmt::Display for AMQPHardError {
195    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
196        match self {
197            AMQPHardError::CONNECTIONFORCED => write!(f, "CONNECTION-FORCED"),
198            AMQPHardError::INVALIDPATH => write!(f, "INVALID-PATH"),
199            AMQPHardError::FRAMEERROR => write!(f, "FRAME-ERROR"),
200            AMQPHardError::SYNTAXERROR => write!(f, "SYNTAX-ERROR"),
201            AMQPHardError::COMMANDINVALID => write!(f, "COMMAND-INVALID"),
202            AMQPHardError::CHANNELERROR => write!(f, "CHANNEL-ERROR"),
203            AMQPHardError::UNEXPECTEDFRAME => write!(f, "UNEXPECTED-FRAME"),
204            AMQPHardError::RESOURCEERROR => write!(f, "RESOURCE-ERROR"),
205            AMQPHardError::NOTALLOWED => write!(f, "NOT-ALLOWED"),
206            AMQPHardError::NOTIMPLEMENTED => write!(f, "NOT-IMPLEMENTED"),
207            AMQPHardError::INTERNALERROR => write!(f, "INTERNAL-ERROR"),
208        }
209    }
210}
211
212use self::access::parse_access;
213use self::basic::parse_basic;
214use self::channel::parse_channel;
215use self::confirm::parse_confirm;
216use self::connection::parse_connection;
217use self::exchange::parse_exchange;
218use self::queue::parse_queue;
219use self::tx::parse_tx;
220/// Parse an AMQP class
221pub fn parse_class<I: ParsableInput>(i: I) -> ParserResult<I, AMQPClass> {
222    context(
223        "parse_class",
224        map_opt(
225            flat_map(parse_id, |id| {
226                move |i| match id {
227                    60 => map(map(parse_basic, AMQPClass::Basic), Some).parse(i),
228                    10 => map(map(parse_connection, AMQPClass::Connection), Some).parse(i),
229                    20 => map(map(parse_channel, AMQPClass::Channel), Some).parse(i),
230                    30 => map(map(parse_access, AMQPClass::Access), Some).parse(i),
231                    40 => map(map(parse_exchange, AMQPClass::Exchange), Some).parse(i),
232                    50 => map(map(parse_queue, AMQPClass::Queue), Some).parse(i),
233                    90 => map(map(parse_tx, AMQPClass::Tx), Some).parse(i),
234                    85 => map(map(parse_confirm, AMQPClass::Confirm), Some).parse(i),
235                    _ => Ok((i, None)),
236                }
237            }),
238            std::convert::identity,
239        ),
240    )
241    .parse(i)
242}
243
244/// Serialize an AMQP class
245pub fn gen_class<'a, W: Write + BackToTheBuffer + 'a>(
246    class: &'a AMQPClass,
247) -> impl SerializeFn<W> + 'a {
248    move |input| match *class {
249        AMQPClass::Basic(ref basic) => basic::gen_basic(basic)(input),
250        AMQPClass::Connection(ref connection) => connection::gen_connection(connection)(input),
251        AMQPClass::Channel(ref channel) => channel::gen_channel(channel)(input),
252        AMQPClass::Access(ref access) => access::gen_access(access)(input),
253        AMQPClass::Exchange(ref exchange) => exchange::gen_exchange(exchange)(input),
254        AMQPClass::Queue(ref queue) => queue::gen_queue(queue)(input),
255        AMQPClass::Tx(ref tx) => tx::gen_tx(tx)(input),
256        AMQPClass::Confirm(ref confirm) => confirm::gen_confirm(confirm)(input),
257    }
258}
259
260/// The available AMQP classes
261#[derive(Clone, Debug, PartialEq)]
262pub enum AMQPClass {
263    /// basic (Generated)
264    Basic(basic::AMQPMethod),
265    /// connection (Generated)
266    Connection(connection::AMQPMethod),
267    /// channel (Generated)
268    Channel(channel::AMQPMethod),
269    /// access (Generated)
270    Access(access::AMQPMethod),
271    /// exchange (Generated)
272    Exchange(exchange::AMQPMethod),
273    /// queue (Generated)
274    Queue(queue::AMQPMethod),
275    /// tx (Generated)
276    Tx(tx::AMQPMethod),
277    /// confirm (Generated)
278    Confirm(confirm::AMQPMethod),
279}
280
281impl AMQPClass {
282    /// Get the AMQP class id (Generated)
283    pub fn get_amqp_class_id(&self) -> Identifier {
284        match self {
285            AMQPClass::Basic(_) => 60,
286            AMQPClass::Connection(_) => 10,
287            AMQPClass::Channel(_) => 20,
288            AMQPClass::Access(_) => 30,
289            AMQPClass::Exchange(_) => 40,
290            AMQPClass::Queue(_) => 50,
291            AMQPClass::Tx(_) => 90,
292            AMQPClass::Confirm(_) => 85,
293        }
294    }
295
296    /// Get the AMQP method id (Generated)
297    pub fn get_amqp_method_id(&self) -> Identifier {
298        match self {
299            AMQPClass::Basic(basic::AMQPMethod::Qos(_)) => 10,
300            AMQPClass::Basic(basic::AMQPMethod::QosOk(_)) => 11,
301            AMQPClass::Basic(basic::AMQPMethod::Consume(_)) => 20,
302            AMQPClass::Basic(basic::AMQPMethod::ConsumeOk(_)) => 21,
303            AMQPClass::Basic(basic::AMQPMethod::Cancel(_)) => 30,
304            AMQPClass::Basic(basic::AMQPMethod::CancelOk(_)) => 31,
305            AMQPClass::Basic(basic::AMQPMethod::Publish(_)) => 40,
306            AMQPClass::Basic(basic::AMQPMethod::Return(_)) => 50,
307            AMQPClass::Basic(basic::AMQPMethod::Deliver(_)) => 60,
308            AMQPClass::Basic(basic::AMQPMethod::Get(_)) => 70,
309            AMQPClass::Basic(basic::AMQPMethod::GetOk(_)) => 71,
310            AMQPClass::Basic(basic::AMQPMethod::GetEmpty(_)) => 72,
311            AMQPClass::Basic(basic::AMQPMethod::Ack(_)) => 80,
312            AMQPClass::Basic(basic::AMQPMethod::Reject(_)) => 90,
313            AMQPClass::Basic(basic::AMQPMethod::RecoverAsync(_)) => 100,
314            AMQPClass::Basic(basic::AMQPMethod::Recover(_)) => 110,
315            AMQPClass::Basic(basic::AMQPMethod::RecoverOk(_)) => 111,
316            AMQPClass::Basic(basic::AMQPMethod::Nack(_)) => 120,
317            AMQPClass::Connection(connection::AMQPMethod::Start(_)) => 10,
318            AMQPClass::Connection(connection::AMQPMethod::StartOk(_)) => 11,
319            AMQPClass::Connection(connection::AMQPMethod::Secure(_)) => 20,
320            AMQPClass::Connection(connection::AMQPMethod::SecureOk(_)) => 21,
321            AMQPClass::Connection(connection::AMQPMethod::Tune(_)) => 30,
322            AMQPClass::Connection(connection::AMQPMethod::TuneOk(_)) => 31,
323            AMQPClass::Connection(connection::AMQPMethod::Open(_)) => 40,
324            AMQPClass::Connection(connection::AMQPMethod::OpenOk(_)) => 41,
325            AMQPClass::Connection(connection::AMQPMethod::Close(_)) => 50,
326            AMQPClass::Connection(connection::AMQPMethod::CloseOk(_)) => 51,
327            AMQPClass::Connection(connection::AMQPMethod::Blocked(_)) => 60,
328            AMQPClass::Connection(connection::AMQPMethod::Unblocked(_)) => 61,
329            AMQPClass::Connection(connection::AMQPMethod::UpdateSecret(_)) => 70,
330            AMQPClass::Connection(connection::AMQPMethod::UpdateSecretOk(_)) => 71,
331            AMQPClass::Channel(channel::AMQPMethod::Open(_)) => 10,
332            AMQPClass::Channel(channel::AMQPMethod::OpenOk(_)) => 11,
333            AMQPClass::Channel(channel::AMQPMethod::Flow(_)) => 20,
334            AMQPClass::Channel(channel::AMQPMethod::FlowOk(_)) => 21,
335            AMQPClass::Channel(channel::AMQPMethod::Close(_)) => 40,
336            AMQPClass::Channel(channel::AMQPMethod::CloseOk(_)) => 41,
337            AMQPClass::Access(access::AMQPMethod::Request(_)) => 10,
338            AMQPClass::Access(access::AMQPMethod::RequestOk(_)) => 11,
339            AMQPClass::Exchange(exchange::AMQPMethod::Declare(_)) => 10,
340            AMQPClass::Exchange(exchange::AMQPMethod::DeclareOk(_)) => 11,
341            AMQPClass::Exchange(exchange::AMQPMethod::Delete(_)) => 20,
342            AMQPClass::Exchange(exchange::AMQPMethod::DeleteOk(_)) => 21,
343            AMQPClass::Exchange(exchange::AMQPMethod::Bind(_)) => 30,
344            AMQPClass::Exchange(exchange::AMQPMethod::BindOk(_)) => 31,
345            AMQPClass::Exchange(exchange::AMQPMethod::Unbind(_)) => 40,
346            AMQPClass::Exchange(exchange::AMQPMethod::UnbindOk(_)) => 51,
347            AMQPClass::Queue(queue::AMQPMethod::Declare(_)) => 10,
348            AMQPClass::Queue(queue::AMQPMethod::DeclareOk(_)) => 11,
349            AMQPClass::Queue(queue::AMQPMethod::Bind(_)) => 20,
350            AMQPClass::Queue(queue::AMQPMethod::BindOk(_)) => 21,
351            AMQPClass::Queue(queue::AMQPMethod::Purge(_)) => 30,
352            AMQPClass::Queue(queue::AMQPMethod::PurgeOk(_)) => 31,
353            AMQPClass::Queue(queue::AMQPMethod::Delete(_)) => 40,
354            AMQPClass::Queue(queue::AMQPMethod::DeleteOk(_)) => 41,
355            AMQPClass::Queue(queue::AMQPMethod::Unbind(_)) => 50,
356            AMQPClass::Queue(queue::AMQPMethod::UnbindOk(_)) => 51,
357            AMQPClass::Tx(tx::AMQPMethod::Select(_)) => 10,
358            AMQPClass::Tx(tx::AMQPMethod::SelectOk(_)) => 11,
359            AMQPClass::Tx(tx::AMQPMethod::Commit(_)) => 20,
360            AMQPClass::Tx(tx::AMQPMethod::CommitOk(_)) => 21,
361            AMQPClass::Tx(tx::AMQPMethod::Rollback(_)) => 30,
362            AMQPClass::Tx(tx::AMQPMethod::RollbackOk(_)) => 31,
363            AMQPClass::Confirm(confirm::AMQPMethod::Select(_)) => 10,
364            AMQPClass::Confirm(confirm::AMQPMethod::SelectOk(_)) => 11,
365        }
366    }
367}
368
369/// basic (generated)
370pub mod basic {
371    use super::*;
372
373    /// Parse basic (Generated)
374    pub fn parse_basic<I: ParsableInput>(i: I) -> ParserResult<I, basic::AMQPMethod> {
375        context(
376            "parse_basic",
377            map_opt(
378                flat_map(parse_id, |id| {
379                    move |i| match id {
380                        10 => context("parse_qos", map(map(parse_qos, AMQPMethod::Qos), Some))
381                            .parse(i),
382                        11 => context(
383                            "parse_qos_ok",
384                            map(map(parse_qos_ok, AMQPMethod::QosOk), Some),
385                        )
386                        .parse(i),
387                        20 => context(
388                            "parse_consume",
389                            map(map(parse_consume, AMQPMethod::Consume), Some),
390                        )
391                        .parse(i),
392                        21 => context(
393                            "parse_consume_ok",
394                            map(map(parse_consume_ok, AMQPMethod::ConsumeOk), Some),
395                        )
396                        .parse(i),
397                        30 => context(
398                            "parse_cancel",
399                            map(map(parse_cancel, AMQPMethod::Cancel), Some),
400                        )
401                        .parse(i),
402                        31 => context(
403                            "parse_cancel_ok",
404                            map(map(parse_cancel_ok, AMQPMethod::CancelOk), Some),
405                        )
406                        .parse(i),
407                        40 => context(
408                            "parse_publish",
409                            map(map(parse_publish, AMQPMethod::Publish), Some),
410                        )
411                        .parse(i),
412                        50 => context(
413                            "parse_return",
414                            map(map(parse_return, AMQPMethod::Return), Some),
415                        )
416                        .parse(i),
417                        60 => context(
418                            "parse_deliver",
419                            map(map(parse_deliver, AMQPMethod::Deliver), Some),
420                        )
421                        .parse(i),
422                        70 => context("parse_get", map(map(parse_get, AMQPMethod::Get), Some))
423                            .parse(i),
424                        71 => context(
425                            "parse_get_ok",
426                            map(map(parse_get_ok, AMQPMethod::GetOk), Some),
427                        )
428                        .parse(i),
429                        72 => context(
430                            "parse_get_empty",
431                            map(map(parse_get_empty, AMQPMethod::GetEmpty), Some),
432                        )
433                        .parse(i),
434                        80 => context("parse_ack", map(map(parse_ack, AMQPMethod::Ack), Some))
435                            .parse(i),
436                        90 => context(
437                            "parse_reject",
438                            map(map(parse_reject, AMQPMethod::Reject), Some),
439                        )
440                        .parse(i),
441                        100 => context(
442                            "parse_recover_async",
443                            map(map(parse_recover_async, AMQPMethod::RecoverAsync), Some),
444                        )
445                        .parse(i),
446                        110 => context(
447                            "parse_recover",
448                            map(map(parse_recover, AMQPMethod::Recover), Some),
449                        )
450                        .parse(i),
451                        111 => context(
452                            "parse_recover_ok",
453                            map(map(parse_recover_ok, AMQPMethod::RecoverOk), Some),
454                        )
455                        .parse(i),
456                        120 => context("parse_nack", map(map(parse_nack, AMQPMethod::Nack), Some))
457                            .parse(i),
458                        _ => Ok((i, None)),
459                    }
460                }),
461                std::convert::identity,
462            ),
463        )
464        .parse(i)
465    }
466
467    /// Serialize basic (Generated)
468    pub fn gen_basic<'a, W: Write + BackToTheBuffer + 'a>(
469        method: &'a AMQPMethod,
470    ) -> impl SerializeFn<W> + 'a {
471        cookie_factory::sequence::pair(gen_id(60), move |input| match *method {
472            AMQPMethod::Qos(ref qos) => gen_qos(qos)(input),
473            AMQPMethod::QosOk(ref qos_ok) => gen_qos_ok(qos_ok)(input),
474            AMQPMethod::Consume(ref consume) => gen_consume(consume)(input),
475            AMQPMethod::ConsumeOk(ref consume_ok) => gen_consume_ok(consume_ok)(input),
476            AMQPMethod::Cancel(ref cancel) => gen_cancel(cancel)(input),
477            AMQPMethod::CancelOk(ref cancel_ok) => gen_cancel_ok(cancel_ok)(input),
478            AMQPMethod::Publish(ref publish) => gen_publish(publish)(input),
479            AMQPMethod::Return(ref r#return) => gen_return(r#return)(input),
480            AMQPMethod::Deliver(ref deliver) => gen_deliver(deliver)(input),
481            AMQPMethod::Get(ref get) => gen_get(get)(input),
482            AMQPMethod::GetOk(ref get_ok) => gen_get_ok(get_ok)(input),
483            AMQPMethod::GetEmpty(ref get_empty) => gen_get_empty(get_empty)(input),
484            AMQPMethod::Ack(ref ack) => gen_ack(ack)(input),
485            AMQPMethod::Reject(ref reject) => gen_reject(reject)(input),
486            AMQPMethod::RecoverAsync(ref recover_async) => gen_recover_async(recover_async)(input),
487            AMQPMethod::Recover(ref recover) => gen_recover(recover)(input),
488            AMQPMethod::RecoverOk(ref recover_ok) => gen_recover_ok(recover_ok)(input),
489            AMQPMethod::Nack(ref nack) => gen_nack(nack)(input),
490        })
491    }
492
493    /// The available methods in basic
494    #[derive(Clone, Debug, PartialEq)]
495    pub enum AMQPMethod {
496        /// qos (Generated)
497        Qos(Qos),
498        /// qos-ok (Generated)
499        QosOk(QosOk),
500        /// consume (Generated)
501        Consume(Consume),
502        /// consume-ok (Generated)
503        ConsumeOk(ConsumeOk),
504        /// cancel (Generated)
505        Cancel(Cancel),
506        /// cancel-ok (Generated)
507        CancelOk(CancelOk),
508        /// publish (Generated)
509        Publish(Publish),
510        /// return (Generated)
511        Return(Return),
512        /// deliver (Generated)
513        Deliver(Deliver),
514        /// get (Generated)
515        Get(Get),
516        /// get-ok (Generated)
517        GetOk(GetOk),
518        /// get-empty (Generated)
519        GetEmpty(GetEmpty),
520        /// ack (Generated)
521        Ack(Ack),
522        /// reject (Generated)
523        Reject(Reject),
524        /// recover-async (Generated)
525        RecoverAsync(RecoverAsync),
526        /// recover (Generated)
527        Recover(Recover),
528        /// recover-ok (Generated)
529        RecoverOk(RecoverOk),
530        /// nack (Generated)
531        Nack(Nack),
532    }
533
534    /// qos (Generated)
535    #[derive(Clone, Debug, Default, PartialEq)]
536    pub struct Qos {
537        /// prefetch-count (Generated)
538        pub prefetch_count: ShortUInt,
539        /// global (Generated)
540        pub global: Boolean,
541    }
542
543    impl Qos {
544        /// Get the AMQP class id for qos (Generated)
545        pub fn get_amqp_class_id(&self) -> Identifier {
546            60
547        }
548
549        /// Get the AMQP method id for qos (Generated)
550        pub fn get_amqp_method_id(&self) -> Identifier {
551            10
552        }
553    }
554
555    /// Parse qos (Generated)
556    pub fn parse_qos<I: ParsableInput>(i: I) -> ParserResult<I, Qos> {
557        let (i, _) = parse_long_uint.parse(i)?;
558        let (i, prefetch_count) = parse_short_uint.parse(i)?;
559        let (i, flags) = parse_flags(i, &["global"])?;
560        Ok((
561            i,
562            Qos {
563                prefetch_count,
564                global: flags.get_flag("global").unwrap_or(false),
565            },
566        ))
567    }
568
569    /// Serialize qos (Generated)
570    pub fn gen_qos<'a, W: Write + BackToTheBuffer + 'a>(
571        method: &'a Qos,
572    ) -> impl SerializeFn<W> + 'a {
573        move |mut input| {
574            let mut flags = AMQPFlags::default();
575            flags.add_flag("global".to_string(), method.global);
576            input = gen_id(10)(input)?;
577            input = gen_long_uint(0)(input)?;
578            input = gen_short_uint(method.prefetch_count)(input)?;
579            input = gen_flags(&flags)(input)?;
580            Ok(input)
581        }
582    }
583    /// qos-ok (Generated)
584    #[derive(Clone, Debug, Default, PartialEq)]
585    pub struct QosOk {}
586
587    impl QosOk {
588        /// Get the AMQP class id for qos-ok (Generated)
589        pub fn get_amqp_class_id(&self) -> Identifier {
590            60
591        }
592
593        /// Get the AMQP method id for qos-ok (Generated)
594        pub fn get_amqp_method_id(&self) -> Identifier {
595            11
596        }
597    }
598
599    /// Parse qos-ok (Generated)
600    pub fn parse_qos_ok<I: ParsableInput>(i: I) -> ParserResult<I, QosOk> {
601        Ok((i, QosOk {}))
602    }
603
604    /// Serialize qos-ok (Generated)
605    pub fn gen_qos_ok<'a, W: Write + BackToTheBuffer + 'a>(
606        _: &'a QosOk,
607    ) -> impl SerializeFn<W> + 'a {
608        move |mut input| {
609            input = gen_id(11)(input)?;
610            Ok(input)
611        }
612    }
613    /// consume (Generated)
614    #[derive(Clone, Debug, Default, PartialEq)]
615    pub struct Consume {
616        /// queue (Generated)
617        pub queue: ShortString,
618        /// consumer-tag (Generated)
619        pub consumer_tag: ShortString,
620        /// no-local (Generated)
621        pub no_local: Boolean,
622        /// no-ack (Generated)
623        pub no_ack: Boolean,
624        /// exclusive (Generated)
625        pub exclusive: Boolean,
626        /// nowait (Generated)
627        pub nowait: Boolean,
628        /// arguments (Generated)
629        pub arguments: FieldTable,
630    }
631
632    impl Consume {
633        /// Get the AMQP class id for consume (Generated)
634        pub fn get_amqp_class_id(&self) -> Identifier {
635            60
636        }
637
638        /// Get the AMQP method id for consume (Generated)
639        pub fn get_amqp_method_id(&self) -> Identifier {
640            20
641        }
642    }
643
644    /// Parse consume (Generated)
645    pub fn parse_consume<I: ParsableInput>(i: I) -> ParserResult<I, Consume> {
646        let (i, _) = parse_short_uint.parse(i)?;
647        let (i, queue) = parse_short_string.parse(i)?;
648        let (i, consumer_tag) = parse_short_string.parse(i)?;
649        let (i, flags) = parse_flags(i, &["no_local", "no_ack", "exclusive", "nowait"])?;
650        let (i, arguments) = parse_field_table.parse(i)?;
651        Ok((
652            i,
653            Consume {
654                queue,
655                consumer_tag,
656                no_local: flags.get_flag("no_local").unwrap_or(false),
657                no_ack: flags.get_flag("no_ack").unwrap_or(false),
658                exclusive: flags.get_flag("exclusive").unwrap_or(false),
659                nowait: flags.get_flag("nowait").unwrap_or(false),
660                arguments,
661            },
662        ))
663    }
664
665    /// Serialize consume (Generated)
666    pub fn gen_consume<'a, W: Write + BackToTheBuffer + 'a>(
667        method: &'a Consume,
668    ) -> impl SerializeFn<W> + 'a {
669        move |mut input| {
670            let mut flags = AMQPFlags::default();
671            flags.add_flag("no_local".to_string(), method.no_local);
672            flags.add_flag("no_ack".to_string(), method.no_ack);
673            flags.add_flag("exclusive".to_string(), method.exclusive);
674            flags.add_flag("nowait".to_string(), method.nowait);
675            input = gen_id(20)(input)?;
676            input = gen_short_uint(0)(input)?;
677            input = gen_short_string(method.queue.as_str())(input)?;
678            input = gen_short_string(method.consumer_tag.as_str())(input)?;
679            input = gen_flags(&flags)(input)?;
680            input = gen_field_table(&method.arguments)(input)?;
681            Ok(input)
682        }
683    }
684    /// consume-ok (Generated)
685    #[derive(Clone, Debug, Default, PartialEq)]
686    pub struct ConsumeOk {
687        /// consumer-tag (Generated)
688        pub consumer_tag: ShortString,
689    }
690
691    impl ConsumeOk {
692        /// Get the AMQP class id for consume-ok (Generated)
693        pub fn get_amqp_class_id(&self) -> Identifier {
694            60
695        }
696
697        /// Get the AMQP method id for consume-ok (Generated)
698        pub fn get_amqp_method_id(&self) -> Identifier {
699            21
700        }
701    }
702
703    /// Parse consume-ok (Generated)
704    pub fn parse_consume_ok<I: ParsableInput>(i: I) -> ParserResult<I, ConsumeOk> {
705        let (i, consumer_tag) = parse_short_string.parse(i)?;
706        Ok((i, ConsumeOk { consumer_tag }))
707    }
708
709    /// Serialize consume-ok (Generated)
710    pub fn gen_consume_ok<'a, W: Write + BackToTheBuffer + 'a>(
711        method: &'a ConsumeOk,
712    ) -> impl SerializeFn<W> + 'a {
713        move |mut input| {
714            input = gen_id(21)(input)?;
715            input = gen_short_string(method.consumer_tag.as_str())(input)?;
716            Ok(input)
717        }
718    }
719    /// cancel (Generated)
720    #[derive(Clone, Debug, Default, PartialEq)]
721    pub struct Cancel {
722        /// consumer-tag (Generated)
723        pub consumer_tag: ShortString,
724        /// nowait (Generated)
725        pub nowait: Boolean,
726    }
727
728    impl Cancel {
729        /// Get the AMQP class id for cancel (Generated)
730        pub fn get_amqp_class_id(&self) -> Identifier {
731            60
732        }
733
734        /// Get the AMQP method id for cancel (Generated)
735        pub fn get_amqp_method_id(&self) -> Identifier {
736            30
737        }
738    }
739
740    /// Parse cancel (Generated)
741    pub fn parse_cancel<I: ParsableInput>(i: I) -> ParserResult<I, Cancel> {
742        let (i, consumer_tag) = parse_short_string.parse(i)?;
743        let (i, flags) = parse_flags(i, &["nowait"])?;
744        Ok((
745            i,
746            Cancel {
747                consumer_tag,
748                nowait: flags.get_flag("nowait").unwrap_or(false),
749            },
750        ))
751    }
752
753    /// Serialize cancel (Generated)
754    pub fn gen_cancel<'a, W: Write + BackToTheBuffer + 'a>(
755        method: &'a Cancel,
756    ) -> impl SerializeFn<W> + 'a {
757        move |mut input| {
758            let mut flags = AMQPFlags::default();
759            flags.add_flag("nowait".to_string(), method.nowait);
760            input = gen_id(30)(input)?;
761            input = gen_short_string(method.consumer_tag.as_str())(input)?;
762            input = gen_flags(&flags)(input)?;
763            Ok(input)
764        }
765    }
766    /// cancel-ok (Generated)
767    #[derive(Clone, Debug, Default, PartialEq)]
768    pub struct CancelOk {
769        /// consumer-tag (Generated)
770        pub consumer_tag: ShortString,
771    }
772
773    impl CancelOk {
774        /// Get the AMQP class id for cancel-ok (Generated)
775        pub fn get_amqp_class_id(&self) -> Identifier {
776            60
777        }
778
779        /// Get the AMQP method id for cancel-ok (Generated)
780        pub fn get_amqp_method_id(&self) -> Identifier {
781            31
782        }
783    }
784
785    /// Parse cancel-ok (Generated)
786    pub fn parse_cancel_ok<I: ParsableInput>(i: I) -> ParserResult<I, CancelOk> {
787        let (i, consumer_tag) = parse_short_string.parse(i)?;
788        Ok((i, CancelOk { consumer_tag }))
789    }
790
791    /// Serialize cancel-ok (Generated)
792    pub fn gen_cancel_ok<'a, W: Write + BackToTheBuffer + 'a>(
793        method: &'a CancelOk,
794    ) -> impl SerializeFn<W> + 'a {
795        move |mut input| {
796            input = gen_id(31)(input)?;
797            input = gen_short_string(method.consumer_tag.as_str())(input)?;
798            Ok(input)
799        }
800    }
801    /// publish (Generated)
802    #[derive(Clone, Debug, Default, PartialEq)]
803    pub struct Publish {
804        /// exchange (Generated)
805        pub exchange: ShortString,
806        /// routing-key (Generated)
807        pub routing_key: ShortString,
808        /// mandatory (Generated)
809        pub mandatory: Boolean,
810        /// immediate (Generated)
811        pub immediate: Boolean,
812    }
813
814    impl Publish {
815        /// Get the AMQP class id for publish (Generated)
816        pub fn get_amqp_class_id(&self) -> Identifier {
817            60
818        }
819
820        /// Get the AMQP method id for publish (Generated)
821        pub fn get_amqp_method_id(&self) -> Identifier {
822            40
823        }
824    }
825
826    /// Parse publish (Generated)
827    pub fn parse_publish<I: ParsableInput>(i: I) -> ParserResult<I, Publish> {
828        let (i, _) = parse_short_uint.parse(i)?;
829        let (i, exchange) = parse_short_string.parse(i)?;
830        let (i, routing_key) = parse_short_string.parse(i)?;
831        let (i, flags) = parse_flags(i, &["mandatory", "immediate"])?;
832        Ok((
833            i,
834            Publish {
835                exchange,
836                routing_key,
837                mandatory: flags.get_flag("mandatory").unwrap_or(false),
838                immediate: flags.get_flag("immediate").unwrap_or(false),
839            },
840        ))
841    }
842
843    /// Serialize publish (Generated)
844    pub fn gen_publish<'a, W: Write + BackToTheBuffer + 'a>(
845        method: &'a Publish,
846    ) -> impl SerializeFn<W> + 'a {
847        move |mut input| {
848            let mut flags = AMQPFlags::default();
849            flags.add_flag("mandatory".to_string(), method.mandatory);
850            flags.add_flag("immediate".to_string(), method.immediate);
851            input = gen_id(40)(input)?;
852            input = gen_short_uint(0)(input)?;
853            input = gen_short_string(method.exchange.as_str())(input)?;
854            input = gen_short_string(method.routing_key.as_str())(input)?;
855            input = gen_flags(&flags)(input)?;
856            Ok(input)
857        }
858    }
859    /// return (Generated)
860    #[derive(Clone, Debug, Default, PartialEq)]
861    pub struct Return {
862        /// reply-code (Generated)
863        pub reply_code: ShortUInt,
864        /// reply-text (Generated)
865        pub reply_text: ShortString,
866        /// exchange (Generated)
867        pub exchange: ShortString,
868        /// routing-key (Generated)
869        pub routing_key: ShortString,
870    }
871
872    impl Return {
873        /// Get the AMQP class id for return (Generated)
874        pub fn get_amqp_class_id(&self) -> Identifier {
875            60
876        }
877
878        /// Get the AMQP method id for return (Generated)
879        pub fn get_amqp_method_id(&self) -> Identifier {
880            50
881        }
882    }
883
884    /// Parse return (Generated)
885    pub fn parse_return<I: ParsableInput>(i: I) -> ParserResult<I, Return> {
886        let (i, reply_code) = parse_short_uint.parse(i)?;
887        let (i, reply_text) = parse_short_string.parse(i)?;
888        let (i, exchange) = parse_short_string.parse(i)?;
889        let (i, routing_key) = parse_short_string.parse(i)?;
890        Ok((
891            i,
892            Return {
893                reply_code,
894                reply_text,
895                exchange,
896                routing_key,
897            },
898        ))
899    }
900
901    /// Serialize return (Generated)
902    pub fn gen_return<'a, W: Write + BackToTheBuffer + 'a>(
903        method: &'a Return,
904    ) -> impl SerializeFn<W> + 'a {
905        move |mut input| {
906            input = gen_id(50)(input)?;
907            input = gen_short_uint(method.reply_code)(input)?;
908            input = gen_short_string(method.reply_text.as_str())(input)?;
909            input = gen_short_string(method.exchange.as_str())(input)?;
910            input = gen_short_string(method.routing_key.as_str())(input)?;
911            Ok(input)
912        }
913    }
914    /// deliver (Generated)
915    #[derive(Clone, Debug, Default, PartialEq)]
916    pub struct Deliver {
917        /// consumer-tag (Generated)
918        pub consumer_tag: ShortString,
919        /// delivery-tag (Generated)
920        pub delivery_tag: LongLongUInt,
921        /// redelivered (Generated)
922        pub redelivered: Boolean,
923        /// exchange (Generated)
924        pub exchange: ShortString,
925        /// routing-key (Generated)
926        pub routing_key: ShortString,
927    }
928
929    impl Deliver {
930        /// Get the AMQP class id for deliver (Generated)
931        pub fn get_amqp_class_id(&self) -> Identifier {
932            60
933        }
934
935        /// Get the AMQP method id for deliver (Generated)
936        pub fn get_amqp_method_id(&self) -> Identifier {
937            60
938        }
939    }
940
941    /// Parse deliver (Generated)
942    pub fn parse_deliver<I: ParsableInput>(i: I) -> ParserResult<I, Deliver> {
943        let (i, consumer_tag) = parse_short_string.parse(i)?;
944        let (i, delivery_tag) = parse_long_long_uint.parse(i)?;
945        let (i, flags) = parse_flags(i, &["redelivered"])?;
946        let (i, exchange) = parse_short_string.parse(i)?;
947        let (i, routing_key) = parse_short_string.parse(i)?;
948        Ok((
949            i,
950            Deliver {
951                consumer_tag,
952                delivery_tag,
953                redelivered: flags.get_flag("redelivered").unwrap_or(false),
954                exchange,
955                routing_key,
956            },
957        ))
958    }
959
960    /// Serialize deliver (Generated)
961    pub fn gen_deliver<'a, W: Write + BackToTheBuffer + 'a>(
962        method: &'a Deliver,
963    ) -> impl SerializeFn<W> + 'a {
964        move |mut input| {
965            let mut flags = AMQPFlags::default();
966            flags.add_flag("redelivered".to_string(), method.redelivered);
967            input = gen_id(60)(input)?;
968            input = gen_short_string(method.consumer_tag.as_str())(input)?;
969            input = gen_long_long_uint(method.delivery_tag)(input)?;
970            input = gen_flags(&flags)(input)?;
971            input = gen_short_string(method.exchange.as_str())(input)?;
972            input = gen_short_string(method.routing_key.as_str())(input)?;
973            Ok(input)
974        }
975    }
976    /// get (Generated)
977    #[derive(Clone, Debug, Default, PartialEq)]
978    pub struct Get {
979        /// queue (Generated)
980        pub queue: ShortString,
981        /// no-ack (Generated)
982        pub no_ack: Boolean,
983    }
984
985    impl Get {
986        /// Get the AMQP class id for get (Generated)
987        pub fn get_amqp_class_id(&self) -> Identifier {
988            60
989        }
990
991        /// Get the AMQP method id for get (Generated)
992        pub fn get_amqp_method_id(&self) -> Identifier {
993            70
994        }
995    }
996
997    /// Parse get (Generated)
998    pub fn parse_get<I: ParsableInput>(i: I) -> ParserResult<I, Get> {
999        let (i, _) = parse_short_uint.parse(i)?;
1000        let (i, queue) = parse_short_string.parse(i)?;
1001        let (i, flags) = parse_flags(i, &["no_ack"])?;
1002        Ok((
1003            i,
1004            Get {
1005                queue,
1006                no_ack: flags.get_flag("no_ack").unwrap_or(false),
1007            },
1008        ))
1009    }
1010
1011    /// Serialize get (Generated)
1012    pub fn gen_get<'a, W: Write + BackToTheBuffer + 'a>(
1013        method: &'a Get,
1014    ) -> impl SerializeFn<W> + 'a {
1015        move |mut input| {
1016            let mut flags = AMQPFlags::default();
1017            flags.add_flag("no_ack".to_string(), method.no_ack);
1018            input = gen_id(70)(input)?;
1019            input = gen_short_uint(0)(input)?;
1020            input = gen_short_string(method.queue.as_str())(input)?;
1021            input = gen_flags(&flags)(input)?;
1022            Ok(input)
1023        }
1024    }
1025    /// get-ok (Generated)
1026    #[derive(Clone, Debug, Default, PartialEq)]
1027    pub struct GetOk {
1028        /// delivery-tag (Generated)
1029        pub delivery_tag: LongLongUInt,
1030        /// redelivered (Generated)
1031        pub redelivered: Boolean,
1032        /// exchange (Generated)
1033        pub exchange: ShortString,
1034        /// routing-key (Generated)
1035        pub routing_key: ShortString,
1036        /// message-count (Generated)
1037        pub message_count: LongUInt,
1038    }
1039
1040    impl GetOk {
1041        /// Get the AMQP class id for get-ok (Generated)
1042        pub fn get_amqp_class_id(&self) -> Identifier {
1043            60
1044        }
1045
1046        /// Get the AMQP method id for get-ok (Generated)
1047        pub fn get_amqp_method_id(&self) -> Identifier {
1048            71
1049        }
1050    }
1051
1052    /// Parse get-ok (Generated)
1053    pub fn parse_get_ok<I: ParsableInput>(i: I) -> ParserResult<I, GetOk> {
1054        let (i, delivery_tag) = parse_long_long_uint.parse(i)?;
1055        let (i, flags) = parse_flags(i, &["redelivered"])?;
1056        let (i, exchange) = parse_short_string.parse(i)?;
1057        let (i, routing_key) = parse_short_string.parse(i)?;
1058        let (i, message_count) = parse_long_uint.parse(i)?;
1059        Ok((
1060            i,
1061            GetOk {
1062                delivery_tag,
1063                redelivered: flags.get_flag("redelivered").unwrap_or(false),
1064                exchange,
1065                routing_key,
1066                message_count,
1067            },
1068        ))
1069    }
1070
1071    /// Serialize get-ok (Generated)
1072    pub fn gen_get_ok<'a, W: Write + BackToTheBuffer + 'a>(
1073        method: &'a GetOk,
1074    ) -> impl SerializeFn<W> + 'a {
1075        move |mut input| {
1076            let mut flags = AMQPFlags::default();
1077            flags.add_flag("redelivered".to_string(), method.redelivered);
1078            input = gen_id(71)(input)?;
1079            input = gen_long_long_uint(method.delivery_tag)(input)?;
1080            input = gen_flags(&flags)(input)?;
1081            input = gen_short_string(method.exchange.as_str())(input)?;
1082            input = gen_short_string(method.routing_key.as_str())(input)?;
1083            input = gen_long_uint(method.message_count)(input)?;
1084            Ok(input)
1085        }
1086    }
1087    /// get-empty (Generated)
1088    #[derive(Clone, Debug, Default, PartialEq)]
1089    pub struct GetEmpty {}
1090
1091    impl GetEmpty {
1092        /// Get the AMQP class id for get-empty (Generated)
1093        pub fn get_amqp_class_id(&self) -> Identifier {
1094            60
1095        }
1096
1097        /// Get the AMQP method id for get-empty (Generated)
1098        pub fn get_amqp_method_id(&self) -> Identifier {
1099            72
1100        }
1101    }
1102
1103    /// Parse get-empty (Generated)
1104    pub fn parse_get_empty<I: ParsableInput>(i: I) -> ParserResult<I, GetEmpty> {
1105        let (i, _) = parse_short_string.parse(i)?;
1106        Ok((i, GetEmpty {}))
1107    }
1108
1109    /// Serialize get-empty (Generated)
1110    pub fn gen_get_empty<'a, W: Write + BackToTheBuffer + 'a>(
1111        _method: &'a GetEmpty,
1112    ) -> impl SerializeFn<W> + 'a {
1113        move |mut input| {
1114            input = gen_id(72)(input)?;
1115            input = gen_short_string("")(input)?;
1116            Ok(input)
1117        }
1118    }
1119    /// ack (Generated)
1120    #[derive(Clone, Debug, Default, PartialEq)]
1121    pub struct Ack {
1122        /// delivery-tag (Generated)
1123        pub delivery_tag: LongLongUInt,
1124        /// multiple (Generated)
1125        pub multiple: Boolean,
1126    }
1127
1128    impl Ack {
1129        /// Get the AMQP class id for ack (Generated)
1130        pub fn get_amqp_class_id(&self) -> Identifier {
1131            60
1132        }
1133
1134        /// Get the AMQP method id for ack (Generated)
1135        pub fn get_amqp_method_id(&self) -> Identifier {
1136            80
1137        }
1138    }
1139
1140    /// Parse ack (Generated)
1141    pub fn parse_ack<I: ParsableInput>(i: I) -> ParserResult<I, Ack> {
1142        let (i, delivery_tag) = parse_long_long_uint.parse(i)?;
1143        let (i, flags) = parse_flags(i, &["multiple"])?;
1144        Ok((
1145            i,
1146            Ack {
1147                delivery_tag,
1148                multiple: flags.get_flag("multiple").unwrap_or(false),
1149            },
1150        ))
1151    }
1152
1153    /// Serialize ack (Generated)
1154    pub fn gen_ack<'a, W: Write + BackToTheBuffer + 'a>(
1155        method: &'a Ack,
1156    ) -> impl SerializeFn<W> + 'a {
1157        move |mut input| {
1158            let mut flags = AMQPFlags::default();
1159            flags.add_flag("multiple".to_string(), method.multiple);
1160            input = gen_id(80)(input)?;
1161            input = gen_long_long_uint(method.delivery_tag)(input)?;
1162            input = gen_flags(&flags)(input)?;
1163            Ok(input)
1164        }
1165    }
1166    /// reject (Generated)
1167    #[derive(Clone, Debug, Default, PartialEq)]
1168    pub struct Reject {
1169        /// delivery-tag (Generated)
1170        pub delivery_tag: LongLongUInt,
1171        /// requeue (Generated)
1172        pub requeue: Boolean,
1173    }
1174
1175    impl Reject {
1176        /// Get the AMQP class id for reject (Generated)
1177        pub fn get_amqp_class_id(&self) -> Identifier {
1178            60
1179        }
1180
1181        /// Get the AMQP method id for reject (Generated)
1182        pub fn get_amqp_method_id(&self) -> Identifier {
1183            90
1184        }
1185    }
1186
1187    /// Parse reject (Generated)
1188    pub fn parse_reject<I: ParsableInput>(i: I) -> ParserResult<I, Reject> {
1189        let (i, delivery_tag) = parse_long_long_uint.parse(i)?;
1190        let (i, flags) = parse_flags(i, &["requeue"])?;
1191        Ok((
1192            i,
1193            Reject {
1194                delivery_tag,
1195                requeue: flags.get_flag("requeue").unwrap_or(false),
1196            },
1197        ))
1198    }
1199
1200    /// Serialize reject (Generated)
1201    pub fn gen_reject<'a, W: Write + BackToTheBuffer + 'a>(
1202        method: &'a Reject,
1203    ) -> impl SerializeFn<W> + 'a {
1204        move |mut input| {
1205            let mut flags = AMQPFlags::default();
1206            flags.add_flag("requeue".to_string(), method.requeue);
1207            input = gen_id(90)(input)?;
1208            input = gen_long_long_uint(method.delivery_tag)(input)?;
1209            input = gen_flags(&flags)(input)?;
1210            Ok(input)
1211        }
1212    }
1213    /// recover-async (Generated)
1214    #[derive(Clone, Debug, Default, PartialEq)]
1215    pub struct RecoverAsync {
1216        /// requeue (Generated)
1217        pub requeue: Boolean,
1218    }
1219
1220    impl RecoverAsync {
1221        /// Get the AMQP class id for recover-async (Generated)
1222        pub fn get_amqp_class_id(&self) -> Identifier {
1223            60
1224        }
1225
1226        /// Get the AMQP method id for recover-async (Generated)
1227        pub fn get_amqp_method_id(&self) -> Identifier {
1228            100
1229        }
1230    }
1231
1232    /// Parse recover-async (Generated)
1233    pub fn parse_recover_async<I: ParsableInput>(i: I) -> ParserResult<I, RecoverAsync> {
1234        let (i, flags) = parse_flags(i, &["requeue"])?;
1235        Ok((
1236            i,
1237            RecoverAsync {
1238                requeue: flags.get_flag("requeue").unwrap_or(false),
1239            },
1240        ))
1241    }
1242
1243    /// Serialize recover-async (Generated)
1244    pub fn gen_recover_async<'a, W: Write + BackToTheBuffer + 'a>(
1245        method: &'a RecoverAsync,
1246    ) -> impl SerializeFn<W> + 'a {
1247        move |mut input| {
1248            let mut flags = AMQPFlags::default();
1249            flags.add_flag("requeue".to_string(), method.requeue);
1250            input = gen_id(100)(input)?;
1251            input = gen_flags(&flags)(input)?;
1252            Ok(input)
1253        }
1254    }
1255    /// recover (Generated)
1256    #[derive(Clone, Debug, Default, PartialEq)]
1257    pub struct Recover {
1258        /// requeue (Generated)
1259        pub requeue: Boolean,
1260    }
1261
1262    impl Recover {
1263        /// Get the AMQP class id for recover (Generated)
1264        pub fn get_amqp_class_id(&self) -> Identifier {
1265            60
1266        }
1267
1268        /// Get the AMQP method id for recover (Generated)
1269        pub fn get_amqp_method_id(&self) -> Identifier {
1270            110
1271        }
1272    }
1273
1274    /// Parse recover (Generated)
1275    pub fn parse_recover<I: ParsableInput>(i: I) -> ParserResult<I, Recover> {
1276        let (i, flags) = parse_flags(i, &["requeue"])?;
1277        Ok((
1278            i,
1279            Recover {
1280                requeue: flags.get_flag("requeue").unwrap_or(false),
1281            },
1282        ))
1283    }
1284
1285    /// Serialize recover (Generated)
1286    pub fn gen_recover<'a, W: Write + BackToTheBuffer + 'a>(
1287        method: &'a Recover,
1288    ) -> impl SerializeFn<W> + 'a {
1289        move |mut input| {
1290            let mut flags = AMQPFlags::default();
1291            flags.add_flag("requeue".to_string(), method.requeue);
1292            input = gen_id(110)(input)?;
1293            input = gen_flags(&flags)(input)?;
1294            Ok(input)
1295        }
1296    }
1297    /// recover-ok (Generated)
1298    #[derive(Clone, Debug, Default, PartialEq)]
1299    pub struct RecoverOk {}
1300
1301    impl RecoverOk {
1302        /// Get the AMQP class id for recover-ok (Generated)
1303        pub fn get_amqp_class_id(&self) -> Identifier {
1304            60
1305        }
1306
1307        /// Get the AMQP method id for recover-ok (Generated)
1308        pub fn get_amqp_method_id(&self) -> Identifier {
1309            111
1310        }
1311    }
1312
1313    /// Parse recover-ok (Generated)
1314    pub fn parse_recover_ok<I: ParsableInput>(i: I) -> ParserResult<I, RecoverOk> {
1315        Ok((i, RecoverOk {}))
1316    }
1317
1318    /// Serialize recover-ok (Generated)
1319    pub fn gen_recover_ok<'a, W: Write + BackToTheBuffer + 'a>(
1320        _: &'a RecoverOk,
1321    ) -> impl SerializeFn<W> + 'a {
1322        move |mut input| {
1323            input = gen_id(111)(input)?;
1324            Ok(input)
1325        }
1326    }
1327    /// nack (Generated)
1328    #[derive(Clone, Debug, Default, PartialEq)]
1329    pub struct Nack {
1330        /// delivery-tag (Generated)
1331        pub delivery_tag: LongLongUInt,
1332        /// multiple (Generated)
1333        pub multiple: Boolean,
1334        /// requeue (Generated)
1335        pub requeue: Boolean,
1336    }
1337
1338    impl Nack {
1339        /// Get the AMQP class id for nack (Generated)
1340        pub fn get_amqp_class_id(&self) -> Identifier {
1341            60
1342        }
1343
1344        /// Get the AMQP method id for nack (Generated)
1345        pub fn get_amqp_method_id(&self) -> Identifier {
1346            120
1347        }
1348    }
1349
1350    /// Parse nack (Generated)
1351    pub fn parse_nack<I: ParsableInput>(i: I) -> ParserResult<I, Nack> {
1352        let (i, delivery_tag) = parse_long_long_uint.parse(i)?;
1353        let (i, flags) = parse_flags(i, &["multiple", "requeue"])?;
1354        Ok((
1355            i,
1356            Nack {
1357                delivery_tag,
1358                multiple: flags.get_flag("multiple").unwrap_or(false),
1359                requeue: flags.get_flag("requeue").unwrap_or(false),
1360            },
1361        ))
1362    }
1363
1364    /// Serialize nack (Generated)
1365    pub fn gen_nack<'a, W: Write + BackToTheBuffer + 'a>(
1366        method: &'a Nack,
1367    ) -> impl SerializeFn<W> + 'a {
1368        move |mut input| {
1369            let mut flags = AMQPFlags::default();
1370            flags.add_flag("multiple".to_string(), method.multiple);
1371            flags.add_flag("requeue".to_string(), method.requeue);
1372            input = gen_id(120)(input)?;
1373            input = gen_long_long_uint(method.delivery_tag)(input)?;
1374            input = gen_flags(&flags)(input)?;
1375            Ok(input)
1376        }
1377    }
1378    /// basic properties (Generated)
1379    #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
1380    pub struct AMQPProperties {
1381        content_type: Option<ShortString>,
1382        content_encoding: Option<ShortString>,
1383        headers: Option<FieldTable>,
1384        delivery_mode: Option<ShortShortUInt>,
1385        priority: Option<ShortShortUInt>,
1386        correlation_id: Option<ShortString>,
1387        reply_to: Option<ShortString>,
1388        expiration: Option<ShortString>,
1389        message_id: Option<ShortString>,
1390        timestamp: Option<Timestamp>,
1391        kind: Option<ShortString>,
1392        user_id: Option<ShortString>,
1393        app_id: Option<ShortString>,
1394        cluster_id: Option<ShortString>,
1395    }
1396
1397    impl AMQPProperties {
1398        /// Set content-type (Generated)
1399        pub fn with_content_type(mut self, value: ShortString) -> Self {
1400            self.content_type = Some(value);
1401            self
1402        }
1403        /// Set content-encoding (Generated)
1404        pub fn with_content_encoding(mut self, value: ShortString) -> Self {
1405            self.content_encoding = Some(value);
1406            self
1407        }
1408        /// Set headers (Generated)
1409        pub fn with_headers(mut self, value: FieldTable) -> Self {
1410            self.headers = Some(value);
1411            self
1412        }
1413        /// Set delivery-mode (Generated)
1414        pub fn with_delivery_mode(mut self, value: ShortShortUInt) -> Self {
1415            self.delivery_mode = Some(value);
1416            self
1417        }
1418        /// Set priority (Generated)
1419        pub fn with_priority(mut self, value: ShortShortUInt) -> Self {
1420            self.priority = Some(value);
1421            self
1422        }
1423        /// Set correlation-id (Generated)
1424        pub fn with_correlation_id(mut self, value: ShortString) -> Self {
1425            self.correlation_id = Some(value);
1426            self
1427        }
1428        /// Set reply-to (Generated)
1429        pub fn with_reply_to(mut self, value: ShortString) -> Self {
1430            self.reply_to = Some(value);
1431            self
1432        }
1433        /// Set expiration (Generated)
1434        pub fn with_expiration(mut self, value: ShortString) -> Self {
1435            self.expiration = Some(value);
1436            self
1437        }
1438        /// Set message-id (Generated)
1439        pub fn with_message_id(mut self, value: ShortString) -> Self {
1440            self.message_id = Some(value);
1441            self
1442        }
1443        /// Set timestamp (Generated)
1444        pub fn with_timestamp(mut self, value: Timestamp) -> Self {
1445            self.timestamp = Some(value);
1446            self
1447        }
1448        /// Set type (Generated)
1449        pub fn with_type(mut self, value: ShortString) -> Self {
1450            self.kind = Some(value);
1451            self
1452        }
1453        /// Set user-id (Generated)
1454        pub fn with_user_id(mut self, value: ShortString) -> Self {
1455            self.user_id = Some(value);
1456            self
1457        }
1458        /// Set app-id (Generated)
1459        pub fn with_app_id(mut self, value: ShortString) -> Self {
1460            self.app_id = Some(value);
1461            self
1462        }
1463        /// Set cluster-id (Generated)
1464        pub fn with_cluster_id(mut self, value: ShortString) -> Self {
1465            self.cluster_id = Some(value);
1466            self
1467        }
1468        /// Get content-type (Generated)
1469        pub fn content_type(&self) -> &Option<ShortString> {
1470            &self.content_type
1471        }
1472        /// Get content-encoding (Generated)
1473        pub fn content_encoding(&self) -> &Option<ShortString> {
1474            &self.content_encoding
1475        }
1476        /// Get headers (Generated)
1477        pub fn headers(&self) -> &Option<FieldTable> {
1478            &self.headers
1479        }
1480        /// Get delivery-mode (Generated)
1481        pub fn delivery_mode(&self) -> &Option<ShortShortUInt> {
1482            &self.delivery_mode
1483        }
1484        /// Get priority (Generated)
1485        pub fn priority(&self) -> &Option<ShortShortUInt> {
1486            &self.priority
1487        }
1488        /// Get correlation-id (Generated)
1489        pub fn correlation_id(&self) -> &Option<ShortString> {
1490            &self.correlation_id
1491        }
1492        /// Get reply-to (Generated)
1493        pub fn reply_to(&self) -> &Option<ShortString> {
1494            &self.reply_to
1495        }
1496        /// Get expiration (Generated)
1497        pub fn expiration(&self) -> &Option<ShortString> {
1498            &self.expiration
1499        }
1500        /// Get message-id (Generated)
1501        pub fn message_id(&self) -> &Option<ShortString> {
1502            &self.message_id
1503        }
1504        /// Get timestamp (Generated)
1505        pub fn timestamp(&self) -> &Option<Timestamp> {
1506            &self.timestamp
1507        }
1508        /// Get type (Generated)
1509        pub fn kind(&self) -> &Option<ShortString> {
1510            &self.kind
1511        }
1512        /// Get user-id (Generated)
1513        pub fn user_id(&self) -> &Option<ShortString> {
1514            &self.user_id
1515        }
1516        /// Get app-id (Generated)
1517        pub fn app_id(&self) -> &Option<ShortString> {
1518            &self.app_id
1519        }
1520        /// Get cluster-id (Generated)
1521        pub fn cluster_id(&self) -> &Option<ShortString> {
1522            &self.cluster_id
1523        }
1524        /// Get the bitmask for serialization (Generated)
1525        #[allow(clippy::identity_op)]
1526        pub fn bitmask(&self) -> ShortUInt {
1527            (if self.content_type.is_some() {
1528                1 << (15 - 0)
1529            } else {
1530                0
1531            }) + (if self.content_encoding.is_some() {
1532                1 << (15 - 1)
1533            } else {
1534                0
1535            }) + (if self.headers.is_some() {
1536                1 << (15 - 2)
1537            } else {
1538                0
1539            }) + (if self.delivery_mode.is_some() {
1540                1 << (15 - 3)
1541            } else {
1542                0
1543            }) + (if self.priority.is_some() {
1544                1 << (15 - 4)
1545            } else {
1546                0
1547            }) + (if self.correlation_id.is_some() {
1548                1 << (15 - 5)
1549            } else {
1550                0
1551            }) + (if self.reply_to.is_some() {
1552                1 << (15 - 6)
1553            } else {
1554                0
1555            }) + (if self.expiration.is_some() {
1556                1 << (15 - 7)
1557            } else {
1558                0
1559            }) + (if self.message_id.is_some() {
1560                1 << (15 - 8)
1561            } else {
1562                0
1563            }) + (if self.timestamp.is_some() {
1564                1 << (15 - 9)
1565            } else {
1566                0
1567            }) + (if self.kind.is_some() {
1568                1 << (15 - 10)
1569            } else {
1570                0
1571            }) + (if self.user_id.is_some() {
1572                1 << (15 - 11)
1573            } else {
1574                0
1575            }) + (if self.app_id.is_some() {
1576                1 << (15 - 12)
1577            } else {
1578                0
1579            }) + (if self.cluster_id.is_some() {
1580                1 << (15 - 13)
1581            } else {
1582                0
1583            })
1584        }
1585    }
1586
1587    /// Parse basic properties (Generated)
1588    #[allow(clippy::identity_op)]
1589    pub fn parse_properties<I: ParsableInput>(i: I) -> ParserResult<I, AMQPProperties> {
1590        let (i, flags) = parse_short_uint(i)?;
1591        let (i, content_type) = if flags & (1 << (15 - 0)) != 0 {
1592            map(parse_short_string, Some).parse(i)?
1593        } else {
1594            (i, None)
1595        };
1596        let (i, content_encoding) = if flags & (1 << (15 - 1)) != 0 {
1597            map(parse_short_string, Some).parse(i)?
1598        } else {
1599            (i, None)
1600        };
1601        let (i, headers) = if flags & (1 << (15 - 2)) != 0 {
1602            map(parse_field_table, Some).parse(i)?
1603        } else {
1604            (i, None)
1605        };
1606        let (i, delivery_mode) = if flags & (1 << (15 - 3)) != 0 {
1607            map(parse_short_short_uint, Some).parse(i)?
1608        } else {
1609            (i, None)
1610        };
1611        let (i, priority) = if flags & (1 << (15 - 4)) != 0 {
1612            map(parse_short_short_uint, Some).parse(i)?
1613        } else {
1614            (i, None)
1615        };
1616        let (i, correlation_id) = if flags & (1 << (15 - 5)) != 0 {
1617            map(parse_short_string, Some).parse(i)?
1618        } else {
1619            (i, None)
1620        };
1621        let (i, reply_to) = if flags & (1 << (15 - 6)) != 0 {
1622            map(parse_short_string, Some).parse(i)?
1623        } else {
1624            (i, None)
1625        };
1626        let (i, expiration) = if flags & (1 << (15 - 7)) != 0 {
1627            map(parse_short_string, Some).parse(i)?
1628        } else {
1629            (i, None)
1630        };
1631        let (i, message_id) = if flags & (1 << (15 - 8)) != 0 {
1632            map(parse_short_string, Some).parse(i)?
1633        } else {
1634            (i, None)
1635        };
1636        let (i, timestamp) = if flags & (1 << (15 - 9)) != 0 {
1637            map(parse_timestamp, Some).parse(i)?
1638        } else {
1639            (i, None)
1640        };
1641        let (i, kind) = if flags & (1 << (15 - 10)) != 0 {
1642            map(parse_short_string, Some).parse(i)?
1643        } else {
1644            (i, None)
1645        };
1646        let (i, user_id) = if flags & (1 << (15 - 11)) != 0 {
1647            map(parse_short_string, Some).parse(i)?
1648        } else {
1649            (i, None)
1650        };
1651        let (i, app_id) = if flags & (1 << (15 - 12)) != 0 {
1652            map(parse_short_string, Some).parse(i)?
1653        } else {
1654            (i, None)
1655        };
1656        let (i, cluster_id) = if flags & (1 << (15 - 13)) != 0 {
1657            map(parse_short_string, Some).parse(i)?
1658        } else {
1659            (i, None)
1660        };
1661        Ok((
1662            i,
1663            AMQPProperties {
1664                content_type,
1665                content_encoding,
1666                headers,
1667                delivery_mode,
1668                priority,
1669                correlation_id,
1670                reply_to,
1671                expiration,
1672                message_id,
1673                timestamp,
1674                kind,
1675                user_id,
1676                app_id,
1677                cluster_id,
1678            },
1679        ))
1680    }
1681
1682    /// Serialize basic properties (Generated)
1683    pub fn gen_properties<'a, W: Write + BackToTheBuffer + 'a>(
1684        props: &'a AMQPProperties,
1685    ) -> impl SerializeFn<W> + 'a {
1686        cookie_factory::sequence::pair(gen_short_uint(props.bitmask()), move |mut input| {
1687            if let Some(prop) = props.content_type.as_ref() {
1688                input = gen_short_string(prop.as_str())(input)?;
1689            }
1690            if let Some(prop) = props.content_encoding.as_ref() {
1691                input = gen_short_string(prop.as_str())(input)?;
1692            }
1693            if let Some(prop) = props.headers.as_ref() {
1694                input = gen_field_table(prop)(input)?;
1695            }
1696            if let Some(prop) = props.delivery_mode {
1697                input = gen_short_short_uint(prop)(input)?;
1698            }
1699            if let Some(prop) = props.priority {
1700                input = gen_short_short_uint(prop)(input)?;
1701            }
1702            if let Some(prop) = props.correlation_id.as_ref() {
1703                input = gen_short_string(prop.as_str())(input)?;
1704            }
1705            if let Some(prop) = props.reply_to.as_ref() {
1706                input = gen_short_string(prop.as_str())(input)?;
1707            }
1708            if let Some(prop) = props.expiration.as_ref() {
1709                input = gen_short_string(prop.as_str())(input)?;
1710            }
1711            if let Some(prop) = props.message_id.as_ref() {
1712                input = gen_short_string(prop.as_str())(input)?;
1713            }
1714            if let Some(prop) = props.timestamp {
1715                input = gen_timestamp(prop)(input)?;
1716            }
1717            if let Some(prop) = props.kind.as_ref() {
1718                input = gen_short_string(prop.as_str())(input)?;
1719            }
1720            if let Some(prop) = props.user_id.as_ref() {
1721                input = gen_short_string(prop.as_str())(input)?;
1722            }
1723            if let Some(prop) = props.app_id.as_ref() {
1724                input = gen_short_string(prop.as_str())(input)?;
1725            }
1726            if let Some(prop) = props.cluster_id.as_ref() {
1727                input = gen_short_string(prop.as_str())(input)?;
1728            }
1729            Ok(input)
1730        })
1731    }
1732}
1733/// connection (generated)
1734pub mod connection {
1735    use super::*;
1736
1737    /// Parse connection (Generated)
1738    pub fn parse_connection<I: ParsableInput>(i: I) -> ParserResult<I, connection::AMQPMethod> {
1739        context(
1740            "parse_connection",
1741            map_opt(
1742                flat_map(parse_id, |id| {
1743                    move |i| match id {
1744                        10 => context(
1745                            "parse_start",
1746                            map(map(parse_start, AMQPMethod::Start), Some),
1747                        )
1748                        .parse(i),
1749                        11 => context(
1750                            "parse_start_ok",
1751                            map(map(parse_start_ok, AMQPMethod::StartOk), Some),
1752                        )
1753                        .parse(i),
1754                        20 => context(
1755                            "parse_secure",
1756                            map(map(parse_secure, AMQPMethod::Secure), Some),
1757                        )
1758                        .parse(i),
1759                        21 => context(
1760                            "parse_secure_ok",
1761                            map(map(parse_secure_ok, AMQPMethod::SecureOk), Some),
1762                        )
1763                        .parse(i),
1764                        30 => context("parse_tune", map(map(parse_tune, AMQPMethod::Tune), Some))
1765                            .parse(i),
1766                        31 => context(
1767                            "parse_tune_ok",
1768                            map(map(parse_tune_ok, AMQPMethod::TuneOk), Some),
1769                        )
1770                        .parse(i),
1771                        40 => context("parse_open", map(map(parse_open, AMQPMethod::Open), Some))
1772                            .parse(i),
1773                        41 => context(
1774                            "parse_open_ok",
1775                            map(map(parse_open_ok, AMQPMethod::OpenOk), Some),
1776                        )
1777                        .parse(i),
1778                        50 => context(
1779                            "parse_close",
1780                            map(map(parse_close, AMQPMethod::Close), Some),
1781                        )
1782                        .parse(i),
1783                        51 => context(
1784                            "parse_close_ok",
1785                            map(map(parse_close_ok, AMQPMethod::CloseOk), Some),
1786                        )
1787                        .parse(i),
1788                        60 => context(
1789                            "parse_blocked",
1790                            map(map(parse_blocked, AMQPMethod::Blocked), Some),
1791                        )
1792                        .parse(i),
1793                        61 => context(
1794                            "parse_unblocked",
1795                            map(map(parse_unblocked, AMQPMethod::Unblocked), Some),
1796                        )
1797                        .parse(i),
1798                        70 => context(
1799                            "parse_update_secret",
1800                            map(map(parse_update_secret, AMQPMethod::UpdateSecret), Some),
1801                        )
1802                        .parse(i),
1803                        71 => context(
1804                            "parse_update_secret_ok",
1805                            map(
1806                                map(parse_update_secret_ok, AMQPMethod::UpdateSecretOk),
1807                                Some,
1808                            ),
1809                        )
1810                        .parse(i),
1811                        _ => Ok((i, None)),
1812                    }
1813                }),
1814                std::convert::identity,
1815            ),
1816        )
1817        .parse(i)
1818    }
1819
1820    /// Serialize connection (Generated)
1821    pub fn gen_connection<'a, W: Write + BackToTheBuffer + 'a>(
1822        method: &'a AMQPMethod,
1823    ) -> impl SerializeFn<W> + 'a {
1824        cookie_factory::sequence::pair(gen_id(10), move |input| match *method {
1825            AMQPMethod::Start(ref start) => gen_start(start)(input),
1826            AMQPMethod::StartOk(ref start_ok) => gen_start_ok(start_ok)(input),
1827            AMQPMethod::Secure(ref secure) => gen_secure(secure)(input),
1828            AMQPMethod::SecureOk(ref secure_ok) => gen_secure_ok(secure_ok)(input),
1829            AMQPMethod::Tune(ref tune) => gen_tune(tune)(input),
1830            AMQPMethod::TuneOk(ref tune_ok) => gen_tune_ok(tune_ok)(input),
1831            AMQPMethod::Open(ref open) => gen_open(open)(input),
1832            AMQPMethod::OpenOk(ref open_ok) => gen_open_ok(open_ok)(input),
1833            AMQPMethod::Close(ref close) => gen_close(close)(input),
1834            AMQPMethod::CloseOk(ref close_ok) => gen_close_ok(close_ok)(input),
1835            AMQPMethod::Blocked(ref blocked) => gen_blocked(blocked)(input),
1836            AMQPMethod::Unblocked(ref unblocked) => gen_unblocked(unblocked)(input),
1837            AMQPMethod::UpdateSecret(ref update_secret) => gen_update_secret(update_secret)(input),
1838            AMQPMethod::UpdateSecretOk(ref update_secret_ok) => {
1839                gen_update_secret_ok(update_secret_ok)(input)
1840            }
1841        })
1842    }
1843
1844    /// The available methods in connection
1845    #[derive(Clone, Debug, PartialEq)]
1846    pub enum AMQPMethod {
1847        /// start (Generated)
1848        Start(Start),
1849        /// start-ok (Generated)
1850        StartOk(StartOk),
1851        /// secure (Generated)
1852        Secure(Secure),
1853        /// secure-ok (Generated)
1854        SecureOk(SecureOk),
1855        /// tune (Generated)
1856        Tune(Tune),
1857        /// tune-ok (Generated)
1858        TuneOk(TuneOk),
1859        /// open (Generated)
1860        Open(Open),
1861        /// open-ok (Generated)
1862        OpenOk(OpenOk),
1863        /// close (Generated)
1864        Close(Close),
1865        /// close-ok (Generated)
1866        CloseOk(CloseOk),
1867        /// blocked (Generated)
1868        Blocked(Blocked),
1869        /// unblocked (Generated)
1870        Unblocked(Unblocked),
1871        /// update-secret (Generated)
1872        UpdateSecret(UpdateSecret),
1873        /// update-secret-ok (Generated)
1874        UpdateSecretOk(UpdateSecretOk),
1875    }
1876
1877    /// start (Generated)
1878    #[derive(Clone, Debug, Default, PartialEq)]
1879    pub struct Start {
1880        /// version-major (Generated)
1881        pub version_major: ShortShortUInt,
1882        /// version-minor (Generated)
1883        pub version_minor: ShortShortUInt,
1884        /// server-properties (Generated)
1885        pub server_properties: FieldTable,
1886        /// mechanisms (Generated)
1887        pub mechanisms: LongString,
1888        /// locales (Generated)
1889        pub locales: LongString,
1890    }
1891
1892    impl Start {
1893        /// Get the AMQP class id for start (Generated)
1894        pub fn get_amqp_class_id(&self) -> Identifier {
1895            10
1896        }
1897
1898        /// Get the AMQP method id for start (Generated)
1899        pub fn get_amqp_method_id(&self) -> Identifier {
1900            10
1901        }
1902    }
1903
1904    /// Parse start (Generated)
1905    pub fn parse_start<I: ParsableInput>(i: I) -> ParserResult<I, Start> {
1906        let (i, version_major) = parse_short_short_uint.parse(i)?;
1907        let (i, version_minor) = parse_short_short_uint.parse(i)?;
1908        let (i, server_properties) = parse_field_table.parse(i)?;
1909        let (i, mechanisms) = parse_long_string.parse(i)?;
1910        let (i, locales) = parse_long_string.parse(i)?;
1911        Ok((
1912            i,
1913            Start {
1914                version_major,
1915                version_minor,
1916                server_properties,
1917                mechanisms,
1918                locales,
1919            },
1920        ))
1921    }
1922
1923    /// Serialize start (Generated)
1924    pub fn gen_start<'a, W: Write + BackToTheBuffer + 'a>(
1925        method: &'a Start,
1926    ) -> impl SerializeFn<W> + 'a {
1927        move |mut input| {
1928            input = gen_id(10)(input)?;
1929            input = gen_short_short_uint(method.version_major)(input)?;
1930            input = gen_short_short_uint(method.version_minor)(input)?;
1931            input = gen_field_table(&method.server_properties)(input)?;
1932            input = gen_long_string(method.mechanisms.as_bytes())(input)?;
1933            input = gen_long_string(method.locales.as_bytes())(input)?;
1934            Ok(input)
1935        }
1936    }
1937    /// start-ok (Generated)
1938    #[derive(Clone, Debug, Default, PartialEq)]
1939    pub struct StartOk {
1940        /// client-properties (Generated)
1941        pub client_properties: FieldTable,
1942        /// mechanism (Generated)
1943        pub mechanism: ShortString,
1944        /// response (Generated)
1945        pub response: LongString,
1946        /// locale (Generated)
1947        pub locale: ShortString,
1948    }
1949
1950    impl StartOk {
1951        /// Get the AMQP class id for start-ok (Generated)
1952        pub fn get_amqp_class_id(&self) -> Identifier {
1953            10
1954        }
1955
1956        /// Get the AMQP method id for start-ok (Generated)
1957        pub fn get_amqp_method_id(&self) -> Identifier {
1958            11
1959        }
1960    }
1961
1962    /// Parse start-ok (Generated)
1963    pub fn parse_start_ok<I: ParsableInput>(i: I) -> ParserResult<I, StartOk> {
1964        let (i, client_properties) = parse_field_table.parse(i)?;
1965        let (i, mechanism) = parse_short_string.parse(i)?;
1966        let (i, response) = parse_long_string.parse(i)?;
1967        let (i, locale) = parse_short_string.parse(i)?;
1968        Ok((
1969            i,
1970            StartOk {
1971                client_properties,
1972                mechanism,
1973                response,
1974                locale,
1975            },
1976        ))
1977    }
1978
1979    /// Serialize start-ok (Generated)
1980    pub fn gen_start_ok<'a, W: Write + BackToTheBuffer + 'a>(
1981        method: &'a StartOk,
1982    ) -> impl SerializeFn<W> + 'a {
1983        move |mut input| {
1984            input = gen_id(11)(input)?;
1985            input = gen_field_table(&method.client_properties)(input)?;
1986            input = gen_short_string(method.mechanism.as_str())(input)?;
1987            input = gen_long_string(method.response.as_bytes())(input)?;
1988            input = gen_short_string(method.locale.as_str())(input)?;
1989            Ok(input)
1990        }
1991    }
1992    /// secure (Generated)
1993    #[derive(Clone, Debug, Default, PartialEq)]
1994    pub struct Secure {
1995        /// challenge (Generated)
1996        pub challenge: LongString,
1997    }
1998
1999    impl Secure {
2000        /// Get the AMQP class id for secure (Generated)
2001        pub fn get_amqp_class_id(&self) -> Identifier {
2002            10
2003        }
2004
2005        /// Get the AMQP method id for secure (Generated)
2006        pub fn get_amqp_method_id(&self) -> Identifier {
2007            20
2008        }
2009    }
2010
2011    /// Parse secure (Generated)
2012    pub fn parse_secure<I: ParsableInput>(i: I) -> ParserResult<I, Secure> {
2013        let (i, challenge) = parse_long_string.parse(i)?;
2014        Ok((i, Secure { challenge }))
2015    }
2016
2017    /// Serialize secure (Generated)
2018    pub fn gen_secure<'a, W: Write + BackToTheBuffer + 'a>(
2019        method: &'a Secure,
2020    ) -> impl SerializeFn<W> + 'a {
2021        move |mut input| {
2022            input = gen_id(20)(input)?;
2023            input = gen_long_string(method.challenge.as_bytes())(input)?;
2024            Ok(input)
2025        }
2026    }
2027    /// secure-ok (Generated)
2028    #[derive(Clone, Debug, Default, PartialEq)]
2029    pub struct SecureOk {
2030        /// response (Generated)
2031        pub response: LongString,
2032    }
2033
2034    impl SecureOk {
2035        /// Get the AMQP class id for secure-ok (Generated)
2036        pub fn get_amqp_class_id(&self) -> Identifier {
2037            10
2038        }
2039
2040        /// Get the AMQP method id for secure-ok (Generated)
2041        pub fn get_amqp_method_id(&self) -> Identifier {
2042            21
2043        }
2044    }
2045
2046    /// Parse secure-ok (Generated)
2047    pub fn parse_secure_ok<I: ParsableInput>(i: I) -> ParserResult<I, SecureOk> {
2048        let (i, response) = parse_long_string.parse(i)?;
2049        Ok((i, SecureOk { response }))
2050    }
2051
2052    /// Serialize secure-ok (Generated)
2053    pub fn gen_secure_ok<'a, W: Write + BackToTheBuffer + 'a>(
2054        method: &'a SecureOk,
2055    ) -> impl SerializeFn<W> + 'a {
2056        move |mut input| {
2057            input = gen_id(21)(input)?;
2058            input = gen_long_string(method.response.as_bytes())(input)?;
2059            Ok(input)
2060        }
2061    }
2062    /// tune (Generated)
2063    #[derive(Clone, Debug, Default, PartialEq)]
2064    pub struct Tune {
2065        /// channel-max (Generated)
2066        pub channel_max: ShortUInt,
2067        /// frame-max (Generated)
2068        pub frame_max: LongUInt,
2069        /// heartbeat (Generated)
2070        pub heartbeat: ShortUInt,
2071    }
2072
2073    impl Tune {
2074        /// Get the AMQP class id for tune (Generated)
2075        pub fn get_amqp_class_id(&self) -> Identifier {
2076            10
2077        }
2078
2079        /// Get the AMQP method id for tune (Generated)
2080        pub fn get_amqp_method_id(&self) -> Identifier {
2081            30
2082        }
2083    }
2084
2085    /// Parse tune (Generated)
2086    pub fn parse_tune<I: ParsableInput>(i: I) -> ParserResult<I, Tune> {
2087        let (i, channel_max) = parse_short_uint.parse(i)?;
2088        let (i, frame_max) = parse_long_uint.parse(i)?;
2089        let (i, heartbeat) = parse_short_uint.parse(i)?;
2090        Ok((
2091            i,
2092            Tune {
2093                channel_max,
2094                frame_max,
2095                heartbeat,
2096            },
2097        ))
2098    }
2099
2100    /// Serialize tune (Generated)
2101    pub fn gen_tune<'a, W: Write + BackToTheBuffer + 'a>(
2102        method: &'a Tune,
2103    ) -> impl SerializeFn<W> + 'a {
2104        move |mut input| {
2105            input = gen_id(30)(input)?;
2106            input = gen_short_uint(method.channel_max)(input)?;
2107            input = gen_long_uint(method.frame_max)(input)?;
2108            input = gen_short_uint(method.heartbeat)(input)?;
2109            Ok(input)
2110        }
2111    }
2112    /// tune-ok (Generated)
2113    #[derive(Clone, Debug, Default, PartialEq)]
2114    pub struct TuneOk {
2115        /// channel-max (Generated)
2116        pub channel_max: ShortUInt,
2117        /// frame-max (Generated)
2118        pub frame_max: LongUInt,
2119        /// heartbeat (Generated)
2120        pub heartbeat: ShortUInt,
2121    }
2122
2123    impl TuneOk {
2124        /// Get the AMQP class id for tune-ok (Generated)
2125        pub fn get_amqp_class_id(&self) -> Identifier {
2126            10
2127        }
2128
2129        /// Get the AMQP method id for tune-ok (Generated)
2130        pub fn get_amqp_method_id(&self) -> Identifier {
2131            31
2132        }
2133    }
2134
2135    /// Parse tune-ok (Generated)
2136    pub fn parse_tune_ok<I: ParsableInput>(i: I) -> ParserResult<I, TuneOk> {
2137        let (i, channel_max) = parse_short_uint.parse(i)?;
2138        let (i, frame_max) = parse_long_uint.parse(i)?;
2139        let (i, heartbeat) = parse_short_uint.parse(i)?;
2140        Ok((
2141            i,
2142            TuneOk {
2143                channel_max,
2144                frame_max,
2145                heartbeat,
2146            },
2147        ))
2148    }
2149
2150    /// Serialize tune-ok (Generated)
2151    pub fn gen_tune_ok<'a, W: Write + BackToTheBuffer + 'a>(
2152        method: &'a TuneOk,
2153    ) -> impl SerializeFn<W> + 'a {
2154        move |mut input| {
2155            input = gen_id(31)(input)?;
2156            input = gen_short_uint(method.channel_max)(input)?;
2157            input = gen_long_uint(method.frame_max)(input)?;
2158            input = gen_short_uint(method.heartbeat)(input)?;
2159            Ok(input)
2160        }
2161    }
2162    /// open (Generated)
2163    #[derive(Clone, Debug, Default, PartialEq)]
2164    pub struct Open {
2165        /// virtual-host (Generated)
2166        pub virtual_host: ShortString,
2167    }
2168
2169    impl Open {
2170        /// Get the AMQP class id for open (Generated)
2171        pub fn get_amqp_class_id(&self) -> Identifier {
2172            10
2173        }
2174
2175        /// Get the AMQP method id for open (Generated)
2176        pub fn get_amqp_method_id(&self) -> Identifier {
2177            40
2178        }
2179    }
2180
2181    /// Parse open (Generated)
2182    pub fn parse_open<I: ParsableInput>(i: I) -> ParserResult<I, Open> {
2183        let (i, virtual_host) = parse_short_string.parse(i)?;
2184        let (i, _) = parse_short_string.parse(i)?;
2185        let (i, _) = parse_flags(i, &["insist"])?;
2186        Ok((i, Open { virtual_host }))
2187    }
2188
2189    /// Serialize open (Generated)
2190    pub fn gen_open<'a, W: Write + BackToTheBuffer + 'a>(
2191        method: &'a Open,
2192    ) -> impl SerializeFn<W> + 'a {
2193        move |mut input| {
2194            let mut flags = AMQPFlags::default();
2195            flags.add_flag("insist".to_string(), false);
2196            input = gen_id(40)(input)?;
2197            input = gen_short_string(method.virtual_host.as_str())(input)?;
2198            input = gen_short_string("")(input)?;
2199            input = gen_flags(&flags)(input)?;
2200            Ok(input)
2201        }
2202    }
2203    /// open-ok (Generated)
2204    #[derive(Clone, Debug, Default, PartialEq)]
2205    pub struct OpenOk {}
2206
2207    impl OpenOk {
2208        /// Get the AMQP class id for open-ok (Generated)
2209        pub fn get_amqp_class_id(&self) -> Identifier {
2210            10
2211        }
2212
2213        /// Get the AMQP method id for open-ok (Generated)
2214        pub fn get_amqp_method_id(&self) -> Identifier {
2215            41
2216        }
2217    }
2218
2219    /// Parse open-ok (Generated)
2220    pub fn parse_open_ok<I: ParsableInput>(i: I) -> ParserResult<I, OpenOk> {
2221        let (i, _) = parse_short_string.parse(i)?;
2222        Ok((i, OpenOk {}))
2223    }
2224
2225    /// Serialize open-ok (Generated)
2226    pub fn gen_open_ok<'a, W: Write + BackToTheBuffer + 'a>(
2227        _method: &'a OpenOk,
2228    ) -> impl SerializeFn<W> + 'a {
2229        move |mut input| {
2230            input = gen_id(41)(input)?;
2231            input = gen_short_string("")(input)?;
2232            Ok(input)
2233        }
2234    }
2235    /// close (Generated)
2236    #[derive(Clone, Debug, Default, PartialEq)]
2237    pub struct Close {
2238        /// reply-code (Generated)
2239        pub reply_code: ShortUInt,
2240        /// reply-text (Generated)
2241        pub reply_text: ShortString,
2242        /// class-id (Generated)
2243        pub class_id: ShortUInt,
2244        /// method-id (Generated)
2245        pub method_id: ShortUInt,
2246    }
2247
2248    impl Close {
2249        /// Get the AMQP class id for close (Generated)
2250        pub fn get_amqp_class_id(&self) -> Identifier {
2251            10
2252        }
2253
2254        /// Get the AMQP method id for close (Generated)
2255        pub fn get_amqp_method_id(&self) -> Identifier {
2256            50
2257        }
2258    }
2259
2260    /// Parse close (Generated)
2261    pub fn parse_close<I: ParsableInput>(i: I) -> ParserResult<I, Close> {
2262        let (i, reply_code) = parse_short_uint.parse(i)?;
2263        let (i, reply_text) = parse_short_string.parse(i)?;
2264        let (i, class_id) = parse_short_uint.parse(i)?;
2265        let (i, method_id) = parse_short_uint.parse(i)?;
2266        Ok((
2267            i,
2268            Close {
2269                reply_code,
2270                reply_text,
2271                class_id,
2272                method_id,
2273            },
2274        ))
2275    }
2276
2277    /// Serialize close (Generated)
2278    pub fn gen_close<'a, W: Write + BackToTheBuffer + 'a>(
2279        method: &'a Close,
2280    ) -> impl SerializeFn<W> + 'a {
2281        move |mut input| {
2282            input = gen_id(50)(input)?;
2283            input = gen_short_uint(method.reply_code)(input)?;
2284            input = gen_short_string(method.reply_text.as_str())(input)?;
2285            input = gen_short_uint(method.class_id)(input)?;
2286            input = gen_short_uint(method.method_id)(input)?;
2287            Ok(input)
2288        }
2289    }
2290    /// close-ok (Generated)
2291    #[derive(Clone, Debug, Default, PartialEq)]
2292    pub struct CloseOk {}
2293
2294    impl CloseOk {
2295        /// Get the AMQP class id for close-ok (Generated)
2296        pub fn get_amqp_class_id(&self) -> Identifier {
2297            10
2298        }
2299
2300        /// Get the AMQP method id for close-ok (Generated)
2301        pub fn get_amqp_method_id(&self) -> Identifier {
2302            51
2303        }
2304    }
2305
2306    /// Parse close-ok (Generated)
2307    pub fn parse_close_ok<I: ParsableInput>(i: I) -> ParserResult<I, CloseOk> {
2308        Ok((i, CloseOk {}))
2309    }
2310
2311    /// Serialize close-ok (Generated)
2312    pub fn gen_close_ok<'a, W: Write + BackToTheBuffer + 'a>(
2313        _: &'a CloseOk,
2314    ) -> impl SerializeFn<W> + 'a {
2315        move |mut input| {
2316            input = gen_id(51)(input)?;
2317            Ok(input)
2318        }
2319    }
2320    /// blocked (Generated)
2321    #[derive(Clone, Debug, Default, PartialEq)]
2322    pub struct Blocked {
2323        /// reason (Generated)
2324        pub reason: ShortString,
2325    }
2326
2327    impl Blocked {
2328        /// Get the AMQP class id for blocked (Generated)
2329        pub fn get_amqp_class_id(&self) -> Identifier {
2330            10
2331        }
2332
2333        /// Get the AMQP method id for blocked (Generated)
2334        pub fn get_amqp_method_id(&self) -> Identifier {
2335            60
2336        }
2337    }
2338
2339    /// Parse blocked (Generated)
2340    pub fn parse_blocked<I: ParsableInput>(i: I) -> ParserResult<I, Blocked> {
2341        let (i, reason) = parse_short_string.parse(i)?;
2342        Ok((i, Blocked { reason }))
2343    }
2344
2345    /// Serialize blocked (Generated)
2346    pub fn gen_blocked<'a, W: Write + BackToTheBuffer + 'a>(
2347        method: &'a Blocked,
2348    ) -> impl SerializeFn<W> + 'a {
2349        move |mut input| {
2350            input = gen_id(60)(input)?;
2351            input = gen_short_string(method.reason.as_str())(input)?;
2352            Ok(input)
2353        }
2354    }
2355    /// unblocked (Generated)
2356    #[derive(Clone, Debug, Default, PartialEq)]
2357    pub struct Unblocked {}
2358
2359    impl Unblocked {
2360        /// Get the AMQP class id for unblocked (Generated)
2361        pub fn get_amqp_class_id(&self) -> Identifier {
2362            10
2363        }
2364
2365        /// Get the AMQP method id for unblocked (Generated)
2366        pub fn get_amqp_method_id(&self) -> Identifier {
2367            61
2368        }
2369    }
2370
2371    /// Parse unblocked (Generated)
2372    pub fn parse_unblocked<I: ParsableInput>(i: I) -> ParserResult<I, Unblocked> {
2373        Ok((i, Unblocked {}))
2374    }
2375
2376    /// Serialize unblocked (Generated)
2377    pub fn gen_unblocked<'a, W: Write + BackToTheBuffer + 'a>(
2378        _: &'a Unblocked,
2379    ) -> impl SerializeFn<W> + 'a {
2380        move |mut input| {
2381            input = gen_id(61)(input)?;
2382            Ok(input)
2383        }
2384    }
2385    /// update-secret (Generated)
2386    #[derive(Clone, Debug, Default, PartialEq)]
2387    pub struct UpdateSecret {
2388        /// new-secret (Generated)
2389        pub new_secret: LongString,
2390        /// reason (Generated)
2391        pub reason: ShortString,
2392    }
2393
2394    impl UpdateSecret {
2395        /// Get the AMQP class id for update-secret (Generated)
2396        pub fn get_amqp_class_id(&self) -> Identifier {
2397            10
2398        }
2399
2400        /// Get the AMQP method id for update-secret (Generated)
2401        pub fn get_amqp_method_id(&self) -> Identifier {
2402            70
2403        }
2404    }
2405
2406    /// Parse update-secret (Generated)
2407    pub fn parse_update_secret<I: ParsableInput>(i: I) -> ParserResult<I, UpdateSecret> {
2408        let (i, new_secret) = parse_long_string.parse(i)?;
2409        let (i, reason) = parse_short_string.parse(i)?;
2410        Ok((i, UpdateSecret { new_secret, reason }))
2411    }
2412
2413    /// Serialize update-secret (Generated)
2414    pub fn gen_update_secret<'a, W: Write + BackToTheBuffer + 'a>(
2415        method: &'a UpdateSecret,
2416    ) -> impl SerializeFn<W> + 'a {
2417        move |mut input| {
2418            input = gen_id(70)(input)?;
2419            input = gen_long_string(method.new_secret.as_bytes())(input)?;
2420            input = gen_short_string(method.reason.as_str())(input)?;
2421            Ok(input)
2422        }
2423    }
2424    /// update-secret-ok (Generated)
2425    #[derive(Clone, Debug, Default, PartialEq)]
2426    pub struct UpdateSecretOk {}
2427
2428    impl UpdateSecretOk {
2429        /// Get the AMQP class id for update-secret-ok (Generated)
2430        pub fn get_amqp_class_id(&self) -> Identifier {
2431            10
2432        }
2433
2434        /// Get the AMQP method id for update-secret-ok (Generated)
2435        pub fn get_amqp_method_id(&self) -> Identifier {
2436            71
2437        }
2438    }
2439
2440    /// Parse update-secret-ok (Generated)
2441    pub fn parse_update_secret_ok<I: ParsableInput>(i: I) -> ParserResult<I, UpdateSecretOk> {
2442        Ok((i, UpdateSecretOk {}))
2443    }
2444
2445    /// Serialize update-secret-ok (Generated)
2446    pub fn gen_update_secret_ok<'a, W: Write + BackToTheBuffer + 'a>(
2447        _: &'a UpdateSecretOk,
2448    ) -> impl SerializeFn<W> + 'a {
2449        move |mut input| {
2450            input = gen_id(71)(input)?;
2451            Ok(input)
2452        }
2453    }
2454}
2455/// channel (generated)
2456pub mod channel {
2457    use super::*;
2458
2459    /// Parse channel (Generated)
2460    pub fn parse_channel<I: ParsableInput>(i: I) -> ParserResult<I, channel::AMQPMethod> {
2461        context(
2462            "parse_channel",
2463            map_opt(
2464                flat_map(parse_id, |id| {
2465                    move |i| match id {
2466                        10 => context("parse_open", map(map(parse_open, AMQPMethod::Open), Some))
2467                            .parse(i),
2468                        11 => context(
2469                            "parse_open_ok",
2470                            map(map(parse_open_ok, AMQPMethod::OpenOk), Some),
2471                        )
2472                        .parse(i),
2473                        20 => context("parse_flow", map(map(parse_flow, AMQPMethod::Flow), Some))
2474                            .parse(i),
2475                        21 => context(
2476                            "parse_flow_ok",
2477                            map(map(parse_flow_ok, AMQPMethod::FlowOk), Some),
2478                        )
2479                        .parse(i),
2480                        40 => context(
2481                            "parse_close",
2482                            map(map(parse_close, AMQPMethod::Close), Some),
2483                        )
2484                        .parse(i),
2485                        41 => context(
2486                            "parse_close_ok",
2487                            map(map(parse_close_ok, AMQPMethod::CloseOk), Some),
2488                        )
2489                        .parse(i),
2490                        _ => Ok((i, None)),
2491                    }
2492                }),
2493                std::convert::identity,
2494            ),
2495        )
2496        .parse(i)
2497    }
2498
2499    /// Serialize channel (Generated)
2500    pub fn gen_channel<'a, W: Write + BackToTheBuffer + 'a>(
2501        method: &'a AMQPMethod,
2502    ) -> impl SerializeFn<W> + 'a {
2503        cookie_factory::sequence::pair(gen_id(20), move |input| match *method {
2504            AMQPMethod::Open(ref open) => gen_open(open)(input),
2505            AMQPMethod::OpenOk(ref open_ok) => gen_open_ok(open_ok)(input),
2506            AMQPMethod::Flow(ref flow) => gen_flow(flow)(input),
2507            AMQPMethod::FlowOk(ref flow_ok) => gen_flow_ok(flow_ok)(input),
2508            AMQPMethod::Close(ref close) => gen_close(close)(input),
2509            AMQPMethod::CloseOk(ref close_ok) => gen_close_ok(close_ok)(input),
2510        })
2511    }
2512
2513    /// The available methods in channel
2514    #[derive(Clone, Debug, PartialEq)]
2515    pub enum AMQPMethod {
2516        /// open (Generated)
2517        Open(Open),
2518        /// open-ok (Generated)
2519        OpenOk(OpenOk),
2520        /// flow (Generated)
2521        Flow(Flow),
2522        /// flow-ok (Generated)
2523        FlowOk(FlowOk),
2524        /// close (Generated)
2525        Close(Close),
2526        /// close-ok (Generated)
2527        CloseOk(CloseOk),
2528    }
2529
2530    /// open (Generated)
2531    #[derive(Clone, Debug, Default, PartialEq)]
2532    pub struct Open {}
2533
2534    impl Open {
2535        /// Get the AMQP class id for open (Generated)
2536        pub fn get_amqp_class_id(&self) -> Identifier {
2537            20
2538        }
2539
2540        /// Get the AMQP method id for open (Generated)
2541        pub fn get_amqp_method_id(&self) -> Identifier {
2542            10
2543        }
2544    }
2545
2546    /// Parse open (Generated)
2547    pub fn parse_open<I: ParsableInput>(i: I) -> ParserResult<I, Open> {
2548        let (i, _) = parse_short_string.parse(i)?;
2549        Ok((i, Open {}))
2550    }
2551
2552    /// Serialize open (Generated)
2553    pub fn gen_open<'a, W: Write + BackToTheBuffer + 'a>(
2554        _method: &'a Open,
2555    ) -> impl SerializeFn<W> + 'a {
2556        move |mut input| {
2557            input = gen_id(10)(input)?;
2558            input = gen_short_string("")(input)?;
2559            Ok(input)
2560        }
2561    }
2562    /// open-ok (Generated)
2563    #[derive(Clone, Debug, Default, PartialEq)]
2564    pub struct OpenOk {}
2565
2566    impl OpenOk {
2567        /// Get the AMQP class id for open-ok (Generated)
2568        pub fn get_amqp_class_id(&self) -> Identifier {
2569            20
2570        }
2571
2572        /// Get the AMQP method id for open-ok (Generated)
2573        pub fn get_amqp_method_id(&self) -> Identifier {
2574            11
2575        }
2576    }
2577
2578    /// Parse open-ok (Generated)
2579    pub fn parse_open_ok<I: ParsableInput>(i: I) -> ParserResult<I, OpenOk> {
2580        let (i, _) = parse_long_string.parse(i)?;
2581        Ok((i, OpenOk {}))
2582    }
2583
2584    /// Serialize open-ok (Generated)
2585    pub fn gen_open_ok<'a, W: Write + BackToTheBuffer + 'a>(
2586        _method: &'a OpenOk,
2587    ) -> impl SerializeFn<W> + 'a {
2588        move |mut input| {
2589            input = gen_id(11)(input)?;
2590            input = gen_long_string(b"")(input)?;
2591            Ok(input)
2592        }
2593    }
2594    /// flow (Generated)
2595    #[derive(Clone, Debug, Default, PartialEq)]
2596    pub struct Flow {
2597        /// active (Generated)
2598        pub active: Boolean,
2599    }
2600
2601    impl Flow {
2602        /// Get the AMQP class id for flow (Generated)
2603        pub fn get_amqp_class_id(&self) -> Identifier {
2604            20
2605        }
2606
2607        /// Get the AMQP method id for flow (Generated)
2608        pub fn get_amqp_method_id(&self) -> Identifier {
2609            20
2610        }
2611    }
2612
2613    /// Parse flow (Generated)
2614    pub fn parse_flow<I: ParsableInput>(i: I) -> ParserResult<I, Flow> {
2615        let (i, flags) = parse_flags(i, &["active"])?;
2616        Ok((
2617            i,
2618            Flow {
2619                active: flags.get_flag("active").unwrap_or(false),
2620            },
2621        ))
2622    }
2623
2624    /// Serialize flow (Generated)
2625    pub fn gen_flow<'a, W: Write + BackToTheBuffer + 'a>(
2626        method: &'a Flow,
2627    ) -> impl SerializeFn<W> + 'a {
2628        move |mut input| {
2629            let mut flags = AMQPFlags::default();
2630            flags.add_flag("active".to_string(), method.active);
2631            input = gen_id(20)(input)?;
2632            input = gen_flags(&flags)(input)?;
2633            Ok(input)
2634        }
2635    }
2636    /// flow-ok (Generated)
2637    #[derive(Clone, Debug, Default, PartialEq)]
2638    pub struct FlowOk {
2639        /// active (Generated)
2640        pub active: Boolean,
2641    }
2642
2643    impl FlowOk {
2644        /// Get the AMQP class id for flow-ok (Generated)
2645        pub fn get_amqp_class_id(&self) -> Identifier {
2646            20
2647        }
2648
2649        /// Get the AMQP method id for flow-ok (Generated)
2650        pub fn get_amqp_method_id(&self) -> Identifier {
2651            21
2652        }
2653    }
2654
2655    /// Parse flow-ok (Generated)
2656    pub fn parse_flow_ok<I: ParsableInput>(i: I) -> ParserResult<I, FlowOk> {
2657        let (i, flags) = parse_flags(i, &["active"])?;
2658        Ok((
2659            i,
2660            FlowOk {
2661                active: flags.get_flag("active").unwrap_or(false),
2662            },
2663        ))
2664    }
2665
2666    /// Serialize flow-ok (Generated)
2667    pub fn gen_flow_ok<'a, W: Write + BackToTheBuffer + 'a>(
2668        method: &'a FlowOk,
2669    ) -> impl SerializeFn<W> + 'a {
2670        move |mut input| {
2671            let mut flags = AMQPFlags::default();
2672            flags.add_flag("active".to_string(), method.active);
2673            input = gen_id(21)(input)?;
2674            input = gen_flags(&flags)(input)?;
2675            Ok(input)
2676        }
2677    }
2678    /// close (Generated)
2679    #[derive(Clone, Debug, Default, PartialEq)]
2680    pub struct Close {
2681        /// reply-code (Generated)
2682        pub reply_code: ShortUInt,
2683        /// reply-text (Generated)
2684        pub reply_text: ShortString,
2685        /// class-id (Generated)
2686        pub class_id: ShortUInt,
2687        /// method-id (Generated)
2688        pub method_id: ShortUInt,
2689    }
2690
2691    impl Close {
2692        /// Get the AMQP class id for close (Generated)
2693        pub fn get_amqp_class_id(&self) -> Identifier {
2694            20
2695        }
2696
2697        /// Get the AMQP method id for close (Generated)
2698        pub fn get_amqp_method_id(&self) -> Identifier {
2699            40
2700        }
2701    }
2702
2703    /// Parse close (Generated)
2704    pub fn parse_close<I: ParsableInput>(i: I) -> ParserResult<I, Close> {
2705        let (i, reply_code) = parse_short_uint.parse(i)?;
2706        let (i, reply_text) = parse_short_string.parse(i)?;
2707        let (i, class_id) = parse_short_uint.parse(i)?;
2708        let (i, method_id) = parse_short_uint.parse(i)?;
2709        Ok((
2710            i,
2711            Close {
2712                reply_code,
2713                reply_text,
2714                class_id,
2715                method_id,
2716            },
2717        ))
2718    }
2719
2720    /// Serialize close (Generated)
2721    pub fn gen_close<'a, W: Write + BackToTheBuffer + 'a>(
2722        method: &'a Close,
2723    ) -> impl SerializeFn<W> + 'a {
2724        move |mut input| {
2725            input = gen_id(40)(input)?;
2726            input = gen_short_uint(method.reply_code)(input)?;
2727            input = gen_short_string(method.reply_text.as_str())(input)?;
2728            input = gen_short_uint(method.class_id)(input)?;
2729            input = gen_short_uint(method.method_id)(input)?;
2730            Ok(input)
2731        }
2732    }
2733    /// close-ok (Generated)
2734    #[derive(Clone, Debug, Default, PartialEq)]
2735    pub struct CloseOk {}
2736
2737    impl CloseOk {
2738        /// Get the AMQP class id for close-ok (Generated)
2739        pub fn get_amqp_class_id(&self) -> Identifier {
2740            20
2741        }
2742
2743        /// Get the AMQP method id for close-ok (Generated)
2744        pub fn get_amqp_method_id(&self) -> Identifier {
2745            41
2746        }
2747    }
2748
2749    /// Parse close-ok (Generated)
2750    pub fn parse_close_ok<I: ParsableInput>(i: I) -> ParserResult<I, CloseOk> {
2751        Ok((i, CloseOk {}))
2752    }
2753
2754    /// Serialize close-ok (Generated)
2755    pub fn gen_close_ok<'a, W: Write + BackToTheBuffer + 'a>(
2756        _: &'a CloseOk,
2757    ) -> impl SerializeFn<W> + 'a {
2758        move |mut input| {
2759            input = gen_id(41)(input)?;
2760            Ok(input)
2761        }
2762    }
2763}
2764/// access (generated)
2765pub mod access {
2766    use super::*;
2767
2768    /// Parse access (Generated)
2769    pub fn parse_access<I: ParsableInput>(i: I) -> ParserResult<I, access::AMQPMethod> {
2770        context(
2771            "parse_access",
2772            map_opt(
2773                flat_map(parse_id, |id| {
2774                    move |i| match id {
2775                        10 => context(
2776                            "parse_request",
2777                            map(map(parse_request, AMQPMethod::Request), Some),
2778                        )
2779                        .parse(i),
2780                        11 => context(
2781                            "parse_request_ok",
2782                            map(map(parse_request_ok, AMQPMethod::RequestOk), Some),
2783                        )
2784                        .parse(i),
2785                        _ => Ok((i, None)),
2786                    }
2787                }),
2788                std::convert::identity,
2789            ),
2790        )
2791        .parse(i)
2792    }
2793
2794    /// Serialize access (Generated)
2795    pub fn gen_access<'a, W: Write + BackToTheBuffer + 'a>(
2796        method: &'a AMQPMethod,
2797    ) -> impl SerializeFn<W> + 'a {
2798        cookie_factory::sequence::pair(gen_id(30), move |input| match *method {
2799            AMQPMethod::Request(ref request) => gen_request(request)(input),
2800            AMQPMethod::RequestOk(ref request_ok) => gen_request_ok(request_ok)(input),
2801        })
2802    }
2803
2804    /// The available methods in access
2805    #[derive(Clone, Debug, PartialEq)]
2806    pub enum AMQPMethod {
2807        /// request (Generated)
2808        Request(Request),
2809        /// request-ok (Generated)
2810        RequestOk(RequestOk),
2811    }
2812
2813    /// request (Generated)
2814    #[derive(Clone, Debug, Default, PartialEq)]
2815    pub struct Request {
2816        /// realm (Generated)
2817        pub realm: ShortString,
2818        /// exclusive (Generated)
2819        pub exclusive: Boolean,
2820        /// passive (Generated)
2821        pub passive: Boolean,
2822        /// active (Generated)
2823        pub active: Boolean,
2824        /// write (Generated)
2825        pub write: Boolean,
2826        /// read (Generated)
2827        pub read: Boolean,
2828    }
2829
2830    impl Request {
2831        /// Get the AMQP class id for request (Generated)
2832        pub fn get_amqp_class_id(&self) -> Identifier {
2833            30
2834        }
2835
2836        /// Get the AMQP method id for request (Generated)
2837        pub fn get_amqp_method_id(&self) -> Identifier {
2838            10
2839        }
2840    }
2841
2842    /// Parse request (Generated)
2843    pub fn parse_request<I: ParsableInput>(i: I) -> ParserResult<I, Request> {
2844        let (i, realm) = parse_short_string.parse(i)?;
2845        let (i, flags) = parse_flags(i, &["exclusive", "passive", "active", "write", "read"])?;
2846        Ok((
2847            i,
2848            Request {
2849                realm,
2850                exclusive: flags.get_flag("exclusive").unwrap_or(false),
2851                passive: flags.get_flag("passive").unwrap_or(false),
2852                active: flags.get_flag("active").unwrap_or(false),
2853                write: flags.get_flag("write").unwrap_or(false),
2854                read: flags.get_flag("read").unwrap_or(false),
2855            },
2856        ))
2857    }
2858
2859    /// Serialize request (Generated)
2860    pub fn gen_request<'a, W: Write + BackToTheBuffer + 'a>(
2861        method: &'a Request,
2862    ) -> impl SerializeFn<W> + 'a {
2863        move |mut input| {
2864            let mut flags = AMQPFlags::default();
2865            flags.add_flag("exclusive".to_string(), method.exclusive);
2866            flags.add_flag("passive".to_string(), method.passive);
2867            flags.add_flag("active".to_string(), method.active);
2868            flags.add_flag("write".to_string(), method.write);
2869            flags.add_flag("read".to_string(), method.read);
2870            input = gen_id(10)(input)?;
2871            input = gen_short_string(method.realm.as_str())(input)?;
2872            input = gen_flags(&flags)(input)?;
2873            Ok(input)
2874        }
2875    }
2876    /// request-ok (Generated)
2877    #[derive(Clone, Debug, Default, PartialEq)]
2878    pub struct RequestOk {}
2879
2880    impl RequestOk {
2881        /// Get the AMQP class id for request-ok (Generated)
2882        pub fn get_amqp_class_id(&self) -> Identifier {
2883            30
2884        }
2885
2886        /// Get the AMQP method id for request-ok (Generated)
2887        pub fn get_amqp_method_id(&self) -> Identifier {
2888            11
2889        }
2890    }
2891
2892    /// Parse request-ok (Generated)
2893    pub fn parse_request_ok<I: ParsableInput>(i: I) -> ParserResult<I, RequestOk> {
2894        let (i, _) = parse_short_uint.parse(i)?;
2895        Ok((i, RequestOk {}))
2896    }
2897
2898    /// Serialize request-ok (Generated)
2899    pub fn gen_request_ok<'a, W: Write + BackToTheBuffer + 'a>(
2900        _method: &'a RequestOk,
2901    ) -> impl SerializeFn<W> + 'a {
2902        move |mut input| {
2903            input = gen_id(11)(input)?;
2904            input = gen_short_uint(1)(input)?;
2905            Ok(input)
2906        }
2907    }
2908}
2909/// exchange (generated)
2910pub mod exchange {
2911    use super::*;
2912
2913    /// Parse exchange (Generated)
2914    pub fn parse_exchange<I: ParsableInput>(i: I) -> ParserResult<I, exchange::AMQPMethod> {
2915        context(
2916            "parse_exchange",
2917            map_opt(
2918                flat_map(parse_id, |id| {
2919                    move |i| match id {
2920                        10 => context(
2921                            "parse_declare",
2922                            map(map(parse_declare, AMQPMethod::Declare), Some),
2923                        )
2924                        .parse(i),
2925                        11 => context(
2926                            "parse_declare_ok",
2927                            map(map(parse_declare_ok, AMQPMethod::DeclareOk), Some),
2928                        )
2929                        .parse(i),
2930                        20 => context(
2931                            "parse_delete",
2932                            map(map(parse_delete, AMQPMethod::Delete), Some),
2933                        )
2934                        .parse(i),
2935                        21 => context(
2936                            "parse_delete_ok",
2937                            map(map(parse_delete_ok, AMQPMethod::DeleteOk), Some),
2938                        )
2939                        .parse(i),
2940                        30 => context("parse_bind", map(map(parse_bind, AMQPMethod::Bind), Some))
2941                            .parse(i),
2942                        31 => context(
2943                            "parse_bind_ok",
2944                            map(map(parse_bind_ok, AMQPMethod::BindOk), Some),
2945                        )
2946                        .parse(i),
2947                        40 => context(
2948                            "parse_unbind",
2949                            map(map(parse_unbind, AMQPMethod::Unbind), Some),
2950                        )
2951                        .parse(i),
2952                        51 => context(
2953                            "parse_unbind_ok",
2954                            map(map(parse_unbind_ok, AMQPMethod::UnbindOk), Some),
2955                        )
2956                        .parse(i),
2957                        _ => Ok((i, None)),
2958                    }
2959                }),
2960                std::convert::identity,
2961            ),
2962        )
2963        .parse(i)
2964    }
2965
2966    /// Serialize exchange (Generated)
2967    pub fn gen_exchange<'a, W: Write + BackToTheBuffer + 'a>(
2968        method: &'a AMQPMethod,
2969    ) -> impl SerializeFn<W> + 'a {
2970        cookie_factory::sequence::pair(gen_id(40), move |input| match *method {
2971            AMQPMethod::Declare(ref declare) => gen_declare(declare)(input),
2972            AMQPMethod::DeclareOk(ref declare_ok) => gen_declare_ok(declare_ok)(input),
2973            AMQPMethod::Delete(ref delete) => gen_delete(delete)(input),
2974            AMQPMethod::DeleteOk(ref delete_ok) => gen_delete_ok(delete_ok)(input),
2975            AMQPMethod::Bind(ref bind) => gen_bind(bind)(input),
2976            AMQPMethod::BindOk(ref bind_ok) => gen_bind_ok(bind_ok)(input),
2977            AMQPMethod::Unbind(ref unbind) => gen_unbind(unbind)(input),
2978            AMQPMethod::UnbindOk(ref unbind_ok) => gen_unbind_ok(unbind_ok)(input),
2979        })
2980    }
2981
2982    /// The available methods in exchange
2983    #[derive(Clone, Debug, PartialEq)]
2984    pub enum AMQPMethod {
2985        /// declare (Generated)
2986        Declare(Declare),
2987        /// declare-ok (Generated)
2988        DeclareOk(DeclareOk),
2989        /// delete (Generated)
2990        Delete(Delete),
2991        /// delete-ok (Generated)
2992        DeleteOk(DeleteOk),
2993        /// bind (Generated)
2994        Bind(Bind),
2995        /// bind-ok (Generated)
2996        BindOk(BindOk),
2997        /// unbind (Generated)
2998        Unbind(Unbind),
2999        /// unbind-ok (Generated)
3000        UnbindOk(UnbindOk),
3001    }
3002
3003    /// declare (Generated)
3004    #[derive(Clone, Debug, Default, PartialEq)]
3005    pub struct Declare {
3006        /// exchange (Generated)
3007        pub exchange: ShortString,
3008        /// type (Generated)
3009        pub kind: ShortString,
3010        /// passive (Generated)
3011        pub passive: Boolean,
3012        /// durable (Generated)
3013        pub durable: Boolean,
3014        /// auto-delete (Generated)
3015        pub auto_delete: Boolean,
3016        /// internal (Generated)
3017        pub internal: Boolean,
3018        /// nowait (Generated)
3019        pub nowait: Boolean,
3020        /// arguments (Generated)
3021        pub arguments: FieldTable,
3022    }
3023
3024    impl Declare {
3025        /// Get the AMQP class id for declare (Generated)
3026        pub fn get_amqp_class_id(&self) -> Identifier {
3027            40
3028        }
3029
3030        /// Get the AMQP method id for declare (Generated)
3031        pub fn get_amqp_method_id(&self) -> Identifier {
3032            10
3033        }
3034    }
3035
3036    /// Parse declare (Generated)
3037    pub fn parse_declare<I: ParsableInput>(i: I) -> ParserResult<I, Declare> {
3038        let (i, _) = parse_short_uint.parse(i)?;
3039        let (i, exchange) = parse_short_string.parse(i)?;
3040        let (i, kind) = parse_short_string.parse(i)?;
3041        let (i, flags) = parse_flags(
3042            i,
3043            &["passive", "durable", "auto_delete", "internal", "nowait"],
3044        )?;
3045        let (i, arguments) = parse_field_table.parse(i)?;
3046        Ok((
3047            i,
3048            Declare {
3049                exchange,
3050                kind,
3051                passive: flags.get_flag("passive").unwrap_or(false),
3052                durable: flags.get_flag("durable").unwrap_or(false),
3053                auto_delete: flags.get_flag("auto_delete").unwrap_or(false),
3054                internal: flags.get_flag("internal").unwrap_or(false),
3055                nowait: flags.get_flag("nowait").unwrap_or(false),
3056                arguments,
3057            },
3058        ))
3059    }
3060
3061    /// Serialize declare (Generated)
3062    pub fn gen_declare<'a, W: Write + BackToTheBuffer + 'a>(
3063        method: &'a Declare,
3064    ) -> impl SerializeFn<W> + 'a {
3065        move |mut input| {
3066            let mut flags = AMQPFlags::default();
3067            flags.add_flag("passive".to_string(), method.passive);
3068            flags.add_flag("durable".to_string(), method.durable);
3069            flags.add_flag("auto_delete".to_string(), method.auto_delete);
3070            flags.add_flag("internal".to_string(), method.internal);
3071            flags.add_flag("nowait".to_string(), method.nowait);
3072            input = gen_id(10)(input)?;
3073            input = gen_short_uint(0)(input)?;
3074            input = gen_short_string(method.exchange.as_str())(input)?;
3075            input = gen_short_string(method.kind.as_str())(input)?;
3076            input = gen_flags(&flags)(input)?;
3077            input = gen_field_table(&method.arguments)(input)?;
3078            Ok(input)
3079        }
3080    }
3081    /// declare-ok (Generated)
3082    #[derive(Clone, Debug, Default, PartialEq)]
3083    pub struct DeclareOk {}
3084
3085    impl DeclareOk {
3086        /// Get the AMQP class id for declare-ok (Generated)
3087        pub fn get_amqp_class_id(&self) -> Identifier {
3088            40
3089        }
3090
3091        /// Get the AMQP method id for declare-ok (Generated)
3092        pub fn get_amqp_method_id(&self) -> Identifier {
3093            11
3094        }
3095    }
3096
3097    /// Parse declare-ok (Generated)
3098    pub fn parse_declare_ok<I: ParsableInput>(i: I) -> ParserResult<I, DeclareOk> {
3099        Ok((i, DeclareOk {}))
3100    }
3101
3102    /// Serialize declare-ok (Generated)
3103    pub fn gen_declare_ok<'a, W: Write + BackToTheBuffer + 'a>(
3104        _: &'a DeclareOk,
3105    ) -> impl SerializeFn<W> + 'a {
3106        move |mut input| {
3107            input = gen_id(11)(input)?;
3108            Ok(input)
3109        }
3110    }
3111    /// delete (Generated)
3112    #[derive(Clone, Debug, Default, PartialEq)]
3113    pub struct Delete {
3114        /// exchange (Generated)
3115        pub exchange: ShortString,
3116        /// if-unused (Generated)
3117        pub if_unused: Boolean,
3118        /// nowait (Generated)
3119        pub nowait: Boolean,
3120    }
3121
3122    impl Delete {
3123        /// Get the AMQP class id for delete (Generated)
3124        pub fn get_amqp_class_id(&self) -> Identifier {
3125            40
3126        }
3127
3128        /// Get the AMQP method id for delete (Generated)
3129        pub fn get_amqp_method_id(&self) -> Identifier {
3130            20
3131        }
3132    }
3133
3134    /// Parse delete (Generated)
3135    pub fn parse_delete<I: ParsableInput>(i: I) -> ParserResult<I, Delete> {
3136        let (i, _) = parse_short_uint.parse(i)?;
3137        let (i, exchange) = parse_short_string.parse(i)?;
3138        let (i, flags) = parse_flags(i, &["if_unused", "nowait"])?;
3139        Ok((
3140            i,
3141            Delete {
3142                exchange,
3143                if_unused: flags.get_flag("if_unused").unwrap_or(false),
3144                nowait: flags.get_flag("nowait").unwrap_or(false),
3145            },
3146        ))
3147    }
3148
3149    /// Serialize delete (Generated)
3150    pub fn gen_delete<'a, W: Write + BackToTheBuffer + 'a>(
3151        method: &'a Delete,
3152    ) -> impl SerializeFn<W> + 'a {
3153        move |mut input| {
3154            let mut flags = AMQPFlags::default();
3155            flags.add_flag("if_unused".to_string(), method.if_unused);
3156            flags.add_flag("nowait".to_string(), method.nowait);
3157            input = gen_id(20)(input)?;
3158            input = gen_short_uint(0)(input)?;
3159            input = gen_short_string(method.exchange.as_str())(input)?;
3160            input = gen_flags(&flags)(input)?;
3161            Ok(input)
3162        }
3163    }
3164    /// delete-ok (Generated)
3165    #[derive(Clone, Debug, Default, PartialEq)]
3166    pub struct DeleteOk {}
3167
3168    impl DeleteOk {
3169        /// Get the AMQP class id for delete-ok (Generated)
3170        pub fn get_amqp_class_id(&self) -> Identifier {
3171            40
3172        }
3173
3174        /// Get the AMQP method id for delete-ok (Generated)
3175        pub fn get_amqp_method_id(&self) -> Identifier {
3176            21
3177        }
3178    }
3179
3180    /// Parse delete-ok (Generated)
3181    pub fn parse_delete_ok<I: ParsableInput>(i: I) -> ParserResult<I, DeleteOk> {
3182        Ok((i, DeleteOk {}))
3183    }
3184
3185    /// Serialize delete-ok (Generated)
3186    pub fn gen_delete_ok<'a, W: Write + BackToTheBuffer + 'a>(
3187        _: &'a DeleteOk,
3188    ) -> impl SerializeFn<W> + 'a {
3189        move |mut input| {
3190            input = gen_id(21)(input)?;
3191            Ok(input)
3192        }
3193    }
3194    /// bind (Generated)
3195    #[derive(Clone, Debug, Default, PartialEq)]
3196    pub struct Bind {
3197        /// destination (Generated)
3198        pub destination: ShortString,
3199        /// source (Generated)
3200        pub source: ShortString,
3201        /// routing-key (Generated)
3202        pub routing_key: ShortString,
3203        /// nowait (Generated)
3204        pub nowait: Boolean,
3205        /// arguments (Generated)
3206        pub arguments: FieldTable,
3207    }
3208
3209    impl Bind {
3210        /// Get the AMQP class id for bind (Generated)
3211        pub fn get_amqp_class_id(&self) -> Identifier {
3212            40
3213        }
3214
3215        /// Get the AMQP method id for bind (Generated)
3216        pub fn get_amqp_method_id(&self) -> Identifier {
3217            30
3218        }
3219    }
3220
3221    /// Parse bind (Generated)
3222    pub fn parse_bind<I: ParsableInput>(i: I) -> ParserResult<I, Bind> {
3223        let (i, _) = parse_short_uint.parse(i)?;
3224        let (i, destination) = parse_short_string.parse(i)?;
3225        let (i, source) = parse_short_string.parse(i)?;
3226        let (i, routing_key) = parse_short_string.parse(i)?;
3227        let (i, flags) = parse_flags(i, &["nowait"])?;
3228        let (i, arguments) = parse_field_table.parse(i)?;
3229        Ok((
3230            i,
3231            Bind {
3232                destination,
3233                source,
3234                routing_key,
3235                nowait: flags.get_flag("nowait").unwrap_or(false),
3236                arguments,
3237            },
3238        ))
3239    }
3240
3241    /// Serialize bind (Generated)
3242    pub fn gen_bind<'a, W: Write + BackToTheBuffer + 'a>(
3243        method: &'a Bind,
3244    ) -> impl SerializeFn<W> + 'a {
3245        move |mut input| {
3246            let mut flags = AMQPFlags::default();
3247            flags.add_flag("nowait".to_string(), method.nowait);
3248            input = gen_id(30)(input)?;
3249            input = gen_short_uint(0)(input)?;
3250            input = gen_short_string(method.destination.as_str())(input)?;
3251            input = gen_short_string(method.source.as_str())(input)?;
3252            input = gen_short_string(method.routing_key.as_str())(input)?;
3253            input = gen_flags(&flags)(input)?;
3254            input = gen_field_table(&method.arguments)(input)?;
3255            Ok(input)
3256        }
3257    }
3258    /// bind-ok (Generated)
3259    #[derive(Clone, Debug, Default, PartialEq)]
3260    pub struct BindOk {}
3261
3262    impl BindOk {
3263        /// Get the AMQP class id for bind-ok (Generated)
3264        pub fn get_amqp_class_id(&self) -> Identifier {
3265            40
3266        }
3267
3268        /// Get the AMQP method id for bind-ok (Generated)
3269        pub fn get_amqp_method_id(&self) -> Identifier {
3270            31
3271        }
3272    }
3273
3274    /// Parse bind-ok (Generated)
3275    pub fn parse_bind_ok<I: ParsableInput>(i: I) -> ParserResult<I, BindOk> {
3276        Ok((i, BindOk {}))
3277    }
3278
3279    /// Serialize bind-ok (Generated)
3280    pub fn gen_bind_ok<'a, W: Write + BackToTheBuffer + 'a>(
3281        _: &'a BindOk,
3282    ) -> impl SerializeFn<W> + 'a {
3283        move |mut input| {
3284            input = gen_id(31)(input)?;
3285            Ok(input)
3286        }
3287    }
3288    /// unbind (Generated)
3289    #[derive(Clone, Debug, Default, PartialEq)]
3290    pub struct Unbind {
3291        /// destination (Generated)
3292        pub destination: ShortString,
3293        /// source (Generated)
3294        pub source: ShortString,
3295        /// routing-key (Generated)
3296        pub routing_key: ShortString,
3297        /// nowait (Generated)
3298        pub nowait: Boolean,
3299        /// arguments (Generated)
3300        pub arguments: FieldTable,
3301    }
3302
3303    impl Unbind {
3304        /// Get the AMQP class id for unbind (Generated)
3305        pub fn get_amqp_class_id(&self) -> Identifier {
3306            40
3307        }
3308
3309        /// Get the AMQP method id for unbind (Generated)
3310        pub fn get_amqp_method_id(&self) -> Identifier {
3311            40
3312        }
3313    }
3314
3315    /// Parse unbind (Generated)
3316    pub fn parse_unbind<I: ParsableInput>(i: I) -> ParserResult<I, Unbind> {
3317        let (i, _) = parse_short_uint.parse(i)?;
3318        let (i, destination) = parse_short_string.parse(i)?;
3319        let (i, source) = parse_short_string.parse(i)?;
3320        let (i, routing_key) = parse_short_string.parse(i)?;
3321        let (i, flags) = parse_flags(i, &["nowait"])?;
3322        let (i, arguments) = parse_field_table.parse(i)?;
3323        Ok((
3324            i,
3325            Unbind {
3326                destination,
3327                source,
3328                routing_key,
3329                nowait: flags.get_flag("nowait").unwrap_or(false),
3330                arguments,
3331            },
3332        ))
3333    }
3334
3335    /// Serialize unbind (Generated)
3336    pub fn gen_unbind<'a, W: Write + BackToTheBuffer + 'a>(
3337        method: &'a Unbind,
3338    ) -> impl SerializeFn<W> + 'a {
3339        move |mut input| {
3340            let mut flags = AMQPFlags::default();
3341            flags.add_flag("nowait".to_string(), method.nowait);
3342            input = gen_id(40)(input)?;
3343            input = gen_short_uint(0)(input)?;
3344            input = gen_short_string(method.destination.as_str())(input)?;
3345            input = gen_short_string(method.source.as_str())(input)?;
3346            input = gen_short_string(method.routing_key.as_str())(input)?;
3347            input = gen_flags(&flags)(input)?;
3348            input = gen_field_table(&method.arguments)(input)?;
3349            Ok(input)
3350        }
3351    }
3352    /// unbind-ok (Generated)
3353    #[derive(Clone, Debug, Default, PartialEq)]
3354    pub struct UnbindOk {}
3355
3356    impl UnbindOk {
3357        /// Get the AMQP class id for unbind-ok (Generated)
3358        pub fn get_amqp_class_id(&self) -> Identifier {
3359            40
3360        }
3361
3362        /// Get the AMQP method id for unbind-ok (Generated)
3363        pub fn get_amqp_method_id(&self) -> Identifier {
3364            51
3365        }
3366    }
3367
3368    /// Parse unbind-ok (Generated)
3369    pub fn parse_unbind_ok<I: ParsableInput>(i: I) -> ParserResult<I, UnbindOk> {
3370        Ok((i, UnbindOk {}))
3371    }
3372
3373    /// Serialize unbind-ok (Generated)
3374    pub fn gen_unbind_ok<'a, W: Write + BackToTheBuffer + 'a>(
3375        _: &'a UnbindOk,
3376    ) -> impl SerializeFn<W> + 'a {
3377        move |mut input| {
3378            input = gen_id(51)(input)?;
3379            Ok(input)
3380        }
3381    }
3382}
3383/// queue (generated)
3384pub mod queue {
3385    use super::*;
3386
3387    /// Parse queue (Generated)
3388    pub fn parse_queue<I: ParsableInput>(i: I) -> ParserResult<I, queue::AMQPMethod> {
3389        context(
3390            "parse_queue",
3391            map_opt(
3392                flat_map(parse_id, |id| {
3393                    move |i| match id {
3394                        10 => context(
3395                            "parse_declare",
3396                            map(map(parse_declare, AMQPMethod::Declare), Some),
3397                        )
3398                        .parse(i),
3399                        11 => context(
3400                            "parse_declare_ok",
3401                            map(map(parse_declare_ok, AMQPMethod::DeclareOk), Some),
3402                        )
3403                        .parse(i),
3404                        20 => context("parse_bind", map(map(parse_bind, AMQPMethod::Bind), Some))
3405                            .parse(i),
3406                        21 => context(
3407                            "parse_bind_ok",
3408                            map(map(parse_bind_ok, AMQPMethod::BindOk), Some),
3409                        )
3410                        .parse(i),
3411                        30 => context(
3412                            "parse_purge",
3413                            map(map(parse_purge, AMQPMethod::Purge), Some),
3414                        )
3415                        .parse(i),
3416                        31 => context(
3417                            "parse_purge_ok",
3418                            map(map(parse_purge_ok, AMQPMethod::PurgeOk), Some),
3419                        )
3420                        .parse(i),
3421                        40 => context(
3422                            "parse_delete",
3423                            map(map(parse_delete, AMQPMethod::Delete), Some),
3424                        )
3425                        .parse(i),
3426                        41 => context(
3427                            "parse_delete_ok",
3428                            map(map(parse_delete_ok, AMQPMethod::DeleteOk), Some),
3429                        )
3430                        .parse(i),
3431                        50 => context(
3432                            "parse_unbind",
3433                            map(map(parse_unbind, AMQPMethod::Unbind), Some),
3434                        )
3435                        .parse(i),
3436                        51 => context(
3437                            "parse_unbind_ok",
3438                            map(map(parse_unbind_ok, AMQPMethod::UnbindOk), Some),
3439                        )
3440                        .parse(i),
3441                        _ => Ok((i, None)),
3442                    }
3443                }),
3444                std::convert::identity,
3445            ),
3446        )
3447        .parse(i)
3448    }
3449
3450    /// Serialize queue (Generated)
3451    pub fn gen_queue<'a, W: Write + BackToTheBuffer + 'a>(
3452        method: &'a AMQPMethod,
3453    ) -> impl SerializeFn<W> + 'a {
3454        cookie_factory::sequence::pair(gen_id(50), move |input| match *method {
3455            AMQPMethod::Declare(ref declare) => gen_declare(declare)(input),
3456            AMQPMethod::DeclareOk(ref declare_ok) => gen_declare_ok(declare_ok)(input),
3457            AMQPMethod::Bind(ref bind) => gen_bind(bind)(input),
3458            AMQPMethod::BindOk(ref bind_ok) => gen_bind_ok(bind_ok)(input),
3459            AMQPMethod::Purge(ref purge) => gen_purge(purge)(input),
3460            AMQPMethod::PurgeOk(ref purge_ok) => gen_purge_ok(purge_ok)(input),
3461            AMQPMethod::Delete(ref delete) => gen_delete(delete)(input),
3462            AMQPMethod::DeleteOk(ref delete_ok) => gen_delete_ok(delete_ok)(input),
3463            AMQPMethod::Unbind(ref unbind) => gen_unbind(unbind)(input),
3464            AMQPMethod::UnbindOk(ref unbind_ok) => gen_unbind_ok(unbind_ok)(input),
3465        })
3466    }
3467
3468    /// The available methods in queue
3469    #[derive(Clone, Debug, PartialEq)]
3470    pub enum AMQPMethod {
3471        /// declare (Generated)
3472        Declare(Declare),
3473        /// declare-ok (Generated)
3474        DeclareOk(DeclareOk),
3475        /// bind (Generated)
3476        Bind(Bind),
3477        /// bind-ok (Generated)
3478        BindOk(BindOk),
3479        /// purge (Generated)
3480        Purge(Purge),
3481        /// purge-ok (Generated)
3482        PurgeOk(PurgeOk),
3483        /// delete (Generated)
3484        Delete(Delete),
3485        /// delete-ok (Generated)
3486        DeleteOk(DeleteOk),
3487        /// unbind (Generated)
3488        Unbind(Unbind),
3489        /// unbind-ok (Generated)
3490        UnbindOk(UnbindOk),
3491    }
3492
3493    /// declare (Generated)
3494    #[derive(Clone, Debug, Default, PartialEq)]
3495    pub struct Declare {
3496        /// queue (Generated)
3497        pub queue: ShortString,
3498        /// passive (Generated)
3499        pub passive: Boolean,
3500        /// durable (Generated)
3501        pub durable: Boolean,
3502        /// exclusive (Generated)
3503        pub exclusive: Boolean,
3504        /// auto-delete (Generated)
3505        pub auto_delete: Boolean,
3506        /// nowait (Generated)
3507        pub nowait: Boolean,
3508        /// arguments (Generated)
3509        pub arguments: FieldTable,
3510    }
3511
3512    impl Declare {
3513        /// Get the AMQP class id for declare (Generated)
3514        pub fn get_amqp_class_id(&self) -> Identifier {
3515            50
3516        }
3517
3518        /// Get the AMQP method id for declare (Generated)
3519        pub fn get_amqp_method_id(&self) -> Identifier {
3520            10
3521        }
3522    }
3523
3524    /// Parse declare (Generated)
3525    pub fn parse_declare<I: ParsableInput>(i: I) -> ParserResult<I, Declare> {
3526        let (i, _) = parse_short_uint.parse(i)?;
3527        let (i, queue) = parse_short_string.parse(i)?;
3528        let (i, flags) = parse_flags(
3529            i,
3530            &["passive", "durable", "exclusive", "auto_delete", "nowait"],
3531        )?;
3532        let (i, arguments) = parse_field_table.parse(i)?;
3533        Ok((
3534            i,
3535            Declare {
3536                queue,
3537                passive: flags.get_flag("passive").unwrap_or(false),
3538                durable: flags.get_flag("durable").unwrap_or(false),
3539                exclusive: flags.get_flag("exclusive").unwrap_or(false),
3540                auto_delete: flags.get_flag("auto_delete").unwrap_or(false),
3541                nowait: flags.get_flag("nowait").unwrap_or(false),
3542                arguments,
3543            },
3544        ))
3545    }
3546
3547    /// Serialize declare (Generated)
3548    pub fn gen_declare<'a, W: Write + BackToTheBuffer + 'a>(
3549        method: &'a Declare,
3550    ) -> impl SerializeFn<W> + 'a {
3551        move |mut input| {
3552            let mut flags = AMQPFlags::default();
3553            flags.add_flag("passive".to_string(), method.passive);
3554            flags.add_flag("durable".to_string(), method.durable);
3555            flags.add_flag("exclusive".to_string(), method.exclusive);
3556            flags.add_flag("auto_delete".to_string(), method.auto_delete);
3557            flags.add_flag("nowait".to_string(), method.nowait);
3558            input = gen_id(10)(input)?;
3559            input = gen_short_uint(0)(input)?;
3560            input = gen_short_string(method.queue.as_str())(input)?;
3561            input = gen_flags(&flags)(input)?;
3562            input = gen_field_table(&method.arguments)(input)?;
3563            Ok(input)
3564        }
3565    }
3566    /// declare-ok (Generated)
3567    #[derive(Clone, Debug, Default, PartialEq)]
3568    pub struct DeclareOk {
3569        /// queue (Generated)
3570        pub queue: ShortString,
3571        /// message-count (Generated)
3572        pub message_count: LongUInt,
3573        /// consumer-count (Generated)
3574        pub consumer_count: LongUInt,
3575    }
3576
3577    impl DeclareOk {
3578        /// Get the AMQP class id for declare-ok (Generated)
3579        pub fn get_amqp_class_id(&self) -> Identifier {
3580            50
3581        }
3582
3583        /// Get the AMQP method id for declare-ok (Generated)
3584        pub fn get_amqp_method_id(&self) -> Identifier {
3585            11
3586        }
3587    }
3588
3589    /// Parse declare-ok (Generated)
3590    pub fn parse_declare_ok<I: ParsableInput>(i: I) -> ParserResult<I, DeclareOk> {
3591        let (i, queue) = parse_short_string.parse(i)?;
3592        let (i, message_count) = parse_long_uint.parse(i)?;
3593        let (i, consumer_count) = parse_long_uint.parse(i)?;
3594        Ok((
3595            i,
3596            DeclareOk {
3597                queue,
3598                message_count,
3599                consumer_count,
3600            },
3601        ))
3602    }
3603
3604    /// Serialize declare-ok (Generated)
3605    pub fn gen_declare_ok<'a, W: Write + BackToTheBuffer + 'a>(
3606        method: &'a DeclareOk,
3607    ) -> impl SerializeFn<W> + 'a {
3608        move |mut input| {
3609            input = gen_id(11)(input)?;
3610            input = gen_short_string(method.queue.as_str())(input)?;
3611            input = gen_long_uint(method.message_count)(input)?;
3612            input = gen_long_uint(method.consumer_count)(input)?;
3613            Ok(input)
3614        }
3615    }
3616    /// bind (Generated)
3617    #[derive(Clone, Debug, Default, PartialEq)]
3618    pub struct Bind {
3619        /// queue (Generated)
3620        pub queue: ShortString,
3621        /// exchange (Generated)
3622        pub exchange: ShortString,
3623        /// routing-key (Generated)
3624        pub routing_key: ShortString,
3625        /// nowait (Generated)
3626        pub nowait: Boolean,
3627        /// arguments (Generated)
3628        pub arguments: FieldTable,
3629    }
3630
3631    impl Bind {
3632        /// Get the AMQP class id for bind (Generated)
3633        pub fn get_amqp_class_id(&self) -> Identifier {
3634            50
3635        }
3636
3637        /// Get the AMQP method id for bind (Generated)
3638        pub fn get_amqp_method_id(&self) -> Identifier {
3639            20
3640        }
3641    }
3642
3643    /// Parse bind (Generated)
3644    pub fn parse_bind<I: ParsableInput>(i: I) -> ParserResult<I, Bind> {
3645        let (i, _) = parse_short_uint.parse(i)?;
3646        let (i, queue) = parse_short_string.parse(i)?;
3647        let (i, exchange) = parse_short_string.parse(i)?;
3648        let (i, routing_key) = parse_short_string.parse(i)?;
3649        let (i, flags) = parse_flags(i, &["nowait"])?;
3650        let (i, arguments) = parse_field_table.parse(i)?;
3651        Ok((
3652            i,
3653            Bind {
3654                queue,
3655                exchange,
3656                routing_key,
3657                nowait: flags.get_flag("nowait").unwrap_or(false),
3658                arguments,
3659            },
3660        ))
3661    }
3662
3663    /// Serialize bind (Generated)
3664    pub fn gen_bind<'a, W: Write + BackToTheBuffer + 'a>(
3665        method: &'a Bind,
3666    ) -> impl SerializeFn<W> + 'a {
3667        move |mut input| {
3668            let mut flags = AMQPFlags::default();
3669            flags.add_flag("nowait".to_string(), method.nowait);
3670            input = gen_id(20)(input)?;
3671            input = gen_short_uint(0)(input)?;
3672            input = gen_short_string(method.queue.as_str())(input)?;
3673            input = gen_short_string(method.exchange.as_str())(input)?;
3674            input = gen_short_string(method.routing_key.as_str())(input)?;
3675            input = gen_flags(&flags)(input)?;
3676            input = gen_field_table(&method.arguments)(input)?;
3677            Ok(input)
3678        }
3679    }
3680    /// bind-ok (Generated)
3681    #[derive(Clone, Debug, Default, PartialEq)]
3682    pub struct BindOk {}
3683
3684    impl BindOk {
3685        /// Get the AMQP class id for bind-ok (Generated)
3686        pub fn get_amqp_class_id(&self) -> Identifier {
3687            50
3688        }
3689
3690        /// Get the AMQP method id for bind-ok (Generated)
3691        pub fn get_amqp_method_id(&self) -> Identifier {
3692            21
3693        }
3694    }
3695
3696    /// Parse bind-ok (Generated)
3697    pub fn parse_bind_ok<I: ParsableInput>(i: I) -> ParserResult<I, BindOk> {
3698        Ok((i, BindOk {}))
3699    }
3700
3701    /// Serialize bind-ok (Generated)
3702    pub fn gen_bind_ok<'a, W: Write + BackToTheBuffer + 'a>(
3703        _: &'a BindOk,
3704    ) -> impl SerializeFn<W> + 'a {
3705        move |mut input| {
3706            input = gen_id(21)(input)?;
3707            Ok(input)
3708        }
3709    }
3710    /// purge (Generated)
3711    #[derive(Clone, Debug, Default, PartialEq)]
3712    pub struct Purge {
3713        /// queue (Generated)
3714        pub queue: ShortString,
3715        /// nowait (Generated)
3716        pub nowait: Boolean,
3717    }
3718
3719    impl Purge {
3720        /// Get the AMQP class id for purge (Generated)
3721        pub fn get_amqp_class_id(&self) -> Identifier {
3722            50
3723        }
3724
3725        /// Get the AMQP method id for purge (Generated)
3726        pub fn get_amqp_method_id(&self) -> Identifier {
3727            30
3728        }
3729    }
3730
3731    /// Parse purge (Generated)
3732    pub fn parse_purge<I: ParsableInput>(i: I) -> ParserResult<I, Purge> {
3733        let (i, _) = parse_short_uint.parse(i)?;
3734        let (i, queue) = parse_short_string.parse(i)?;
3735        let (i, flags) = parse_flags(i, &["nowait"])?;
3736        Ok((
3737            i,
3738            Purge {
3739                queue,
3740                nowait: flags.get_flag("nowait").unwrap_or(false),
3741            },
3742        ))
3743    }
3744
3745    /// Serialize purge (Generated)
3746    pub fn gen_purge<'a, W: Write + BackToTheBuffer + 'a>(
3747        method: &'a Purge,
3748    ) -> impl SerializeFn<W> + 'a {
3749        move |mut input| {
3750            let mut flags = AMQPFlags::default();
3751            flags.add_flag("nowait".to_string(), method.nowait);
3752            input = gen_id(30)(input)?;
3753            input = gen_short_uint(0)(input)?;
3754            input = gen_short_string(method.queue.as_str())(input)?;
3755            input = gen_flags(&flags)(input)?;
3756            Ok(input)
3757        }
3758    }
3759    /// purge-ok (Generated)
3760    #[derive(Clone, Debug, Default, PartialEq)]
3761    pub struct PurgeOk {
3762        /// message-count (Generated)
3763        pub message_count: LongUInt,
3764    }
3765
3766    impl PurgeOk {
3767        /// Get the AMQP class id for purge-ok (Generated)
3768        pub fn get_amqp_class_id(&self) -> Identifier {
3769            50
3770        }
3771
3772        /// Get the AMQP method id for purge-ok (Generated)
3773        pub fn get_amqp_method_id(&self) -> Identifier {
3774            31
3775        }
3776    }
3777
3778    /// Parse purge-ok (Generated)
3779    pub fn parse_purge_ok<I: ParsableInput>(i: I) -> ParserResult<I, PurgeOk> {
3780        let (i, message_count) = parse_long_uint.parse(i)?;
3781        Ok((i, PurgeOk { message_count }))
3782    }
3783
3784    /// Serialize purge-ok (Generated)
3785    pub fn gen_purge_ok<'a, W: Write + BackToTheBuffer + 'a>(
3786        method: &'a PurgeOk,
3787    ) -> impl SerializeFn<W> + 'a {
3788        move |mut input| {
3789            input = gen_id(31)(input)?;
3790            input = gen_long_uint(method.message_count)(input)?;
3791            Ok(input)
3792        }
3793    }
3794    /// delete (Generated)
3795    #[derive(Clone, Debug, Default, PartialEq)]
3796    pub struct Delete {
3797        /// queue (Generated)
3798        pub queue: ShortString,
3799        /// if-unused (Generated)
3800        pub if_unused: Boolean,
3801        /// if-empty (Generated)
3802        pub if_empty: Boolean,
3803        /// nowait (Generated)
3804        pub nowait: Boolean,
3805    }
3806
3807    impl Delete {
3808        /// Get the AMQP class id for delete (Generated)
3809        pub fn get_amqp_class_id(&self) -> Identifier {
3810            50
3811        }
3812
3813        /// Get the AMQP method id for delete (Generated)
3814        pub fn get_amqp_method_id(&self) -> Identifier {
3815            40
3816        }
3817    }
3818
3819    /// Parse delete (Generated)
3820    pub fn parse_delete<I: ParsableInput>(i: I) -> ParserResult<I, Delete> {
3821        let (i, _) = parse_short_uint.parse(i)?;
3822        let (i, queue) = parse_short_string.parse(i)?;
3823        let (i, flags) = parse_flags(i, &["if_unused", "if_empty", "nowait"])?;
3824        Ok((
3825            i,
3826            Delete {
3827                queue,
3828                if_unused: flags.get_flag("if_unused").unwrap_or(false),
3829                if_empty: flags.get_flag("if_empty").unwrap_or(false),
3830                nowait: flags.get_flag("nowait").unwrap_or(false),
3831            },
3832        ))
3833    }
3834
3835    /// Serialize delete (Generated)
3836    pub fn gen_delete<'a, W: Write + BackToTheBuffer + 'a>(
3837        method: &'a Delete,
3838    ) -> impl SerializeFn<W> + 'a {
3839        move |mut input| {
3840            let mut flags = AMQPFlags::default();
3841            flags.add_flag("if_unused".to_string(), method.if_unused);
3842            flags.add_flag("if_empty".to_string(), method.if_empty);
3843            flags.add_flag("nowait".to_string(), method.nowait);
3844            input = gen_id(40)(input)?;
3845            input = gen_short_uint(0)(input)?;
3846            input = gen_short_string(method.queue.as_str())(input)?;
3847            input = gen_flags(&flags)(input)?;
3848            Ok(input)
3849        }
3850    }
3851    /// delete-ok (Generated)
3852    #[derive(Clone, Debug, Default, PartialEq)]
3853    pub struct DeleteOk {
3854        /// message-count (Generated)
3855        pub message_count: LongUInt,
3856    }
3857
3858    impl DeleteOk {
3859        /// Get the AMQP class id for delete-ok (Generated)
3860        pub fn get_amqp_class_id(&self) -> Identifier {
3861            50
3862        }
3863
3864        /// Get the AMQP method id for delete-ok (Generated)
3865        pub fn get_amqp_method_id(&self) -> Identifier {
3866            41
3867        }
3868    }
3869
3870    /// Parse delete-ok (Generated)
3871    pub fn parse_delete_ok<I: ParsableInput>(i: I) -> ParserResult<I, DeleteOk> {
3872        let (i, message_count) = parse_long_uint.parse(i)?;
3873        Ok((i, DeleteOk { message_count }))
3874    }
3875
3876    /// Serialize delete-ok (Generated)
3877    pub fn gen_delete_ok<'a, W: Write + BackToTheBuffer + 'a>(
3878        method: &'a DeleteOk,
3879    ) -> impl SerializeFn<W> + 'a {
3880        move |mut input| {
3881            input = gen_id(41)(input)?;
3882            input = gen_long_uint(method.message_count)(input)?;
3883            Ok(input)
3884        }
3885    }
3886    /// unbind (Generated)
3887    #[derive(Clone, Debug, Default, PartialEq)]
3888    pub struct Unbind {
3889        /// queue (Generated)
3890        pub queue: ShortString,
3891        /// exchange (Generated)
3892        pub exchange: ShortString,
3893        /// routing-key (Generated)
3894        pub routing_key: ShortString,
3895        /// arguments (Generated)
3896        pub arguments: FieldTable,
3897    }
3898
3899    impl Unbind {
3900        /// Get the AMQP class id for unbind (Generated)
3901        pub fn get_amqp_class_id(&self) -> Identifier {
3902            50
3903        }
3904
3905        /// Get the AMQP method id for unbind (Generated)
3906        pub fn get_amqp_method_id(&self) -> Identifier {
3907            50
3908        }
3909    }
3910
3911    /// Parse unbind (Generated)
3912    pub fn parse_unbind<I: ParsableInput>(i: I) -> ParserResult<I, Unbind> {
3913        let (i, _) = parse_short_uint.parse(i)?;
3914        let (i, queue) = parse_short_string.parse(i)?;
3915        let (i, exchange) = parse_short_string.parse(i)?;
3916        let (i, routing_key) = parse_short_string.parse(i)?;
3917        let (i, arguments) = parse_field_table.parse(i)?;
3918        Ok((
3919            i,
3920            Unbind {
3921                queue,
3922                exchange,
3923                routing_key,
3924                arguments,
3925            },
3926        ))
3927    }
3928
3929    /// Serialize unbind (Generated)
3930    pub fn gen_unbind<'a, W: Write + BackToTheBuffer + 'a>(
3931        method: &'a Unbind,
3932    ) -> impl SerializeFn<W> + 'a {
3933        move |mut input| {
3934            input = gen_id(50)(input)?;
3935            input = gen_short_uint(0)(input)?;
3936            input = gen_short_string(method.queue.as_str())(input)?;
3937            input = gen_short_string(method.exchange.as_str())(input)?;
3938            input = gen_short_string(method.routing_key.as_str())(input)?;
3939            input = gen_field_table(&method.arguments)(input)?;
3940            Ok(input)
3941        }
3942    }
3943    /// unbind-ok (Generated)
3944    #[derive(Clone, Debug, Default, PartialEq)]
3945    pub struct UnbindOk {}
3946
3947    impl UnbindOk {
3948        /// Get the AMQP class id for unbind-ok (Generated)
3949        pub fn get_amqp_class_id(&self) -> Identifier {
3950            50
3951        }
3952
3953        /// Get the AMQP method id for unbind-ok (Generated)
3954        pub fn get_amqp_method_id(&self) -> Identifier {
3955            51
3956        }
3957    }
3958
3959    /// Parse unbind-ok (Generated)
3960    pub fn parse_unbind_ok<I: ParsableInput>(i: I) -> ParserResult<I, UnbindOk> {
3961        Ok((i, UnbindOk {}))
3962    }
3963
3964    /// Serialize unbind-ok (Generated)
3965    pub fn gen_unbind_ok<'a, W: Write + BackToTheBuffer + 'a>(
3966        _: &'a UnbindOk,
3967    ) -> impl SerializeFn<W> + 'a {
3968        move |mut input| {
3969            input = gen_id(51)(input)?;
3970            Ok(input)
3971        }
3972    }
3973}
3974/// tx (generated)
3975pub mod tx {
3976    use super::*;
3977
3978    /// Parse tx (Generated)
3979    pub fn parse_tx<I: ParsableInput>(i: I) -> ParserResult<I, tx::AMQPMethod> {
3980        context(
3981            "parse_tx",
3982            map_opt(
3983                flat_map(parse_id, |id| {
3984                    move |i| match id {
3985                        10 => context(
3986                            "parse_select",
3987                            map(map(parse_select, AMQPMethod::Select), Some),
3988                        )
3989                        .parse(i),
3990                        11 => context(
3991                            "parse_select_ok",
3992                            map(map(parse_select_ok, AMQPMethod::SelectOk), Some),
3993                        )
3994                        .parse(i),
3995                        20 => context(
3996                            "parse_commit",
3997                            map(map(parse_commit, AMQPMethod::Commit), Some),
3998                        )
3999                        .parse(i),
4000                        21 => context(
4001                            "parse_commit_ok",
4002                            map(map(parse_commit_ok, AMQPMethod::CommitOk), Some),
4003                        )
4004                        .parse(i),
4005                        30 => context(
4006                            "parse_rollback",
4007                            map(map(parse_rollback, AMQPMethod::Rollback), Some),
4008                        )
4009                        .parse(i),
4010                        31 => context(
4011                            "parse_rollback_ok",
4012                            map(map(parse_rollback_ok, AMQPMethod::RollbackOk), Some),
4013                        )
4014                        .parse(i),
4015                        _ => Ok((i, None)),
4016                    }
4017                }),
4018                std::convert::identity,
4019            ),
4020        )
4021        .parse(i)
4022    }
4023
4024    /// Serialize tx (Generated)
4025    pub fn gen_tx<'a, W: Write + BackToTheBuffer + 'a>(
4026        method: &'a AMQPMethod,
4027    ) -> impl SerializeFn<W> + 'a {
4028        cookie_factory::sequence::pair(gen_id(90), move |input| match *method {
4029            AMQPMethod::Select(ref select) => gen_select(select)(input),
4030            AMQPMethod::SelectOk(ref select_ok) => gen_select_ok(select_ok)(input),
4031            AMQPMethod::Commit(ref commit) => gen_commit(commit)(input),
4032            AMQPMethod::CommitOk(ref commit_ok) => gen_commit_ok(commit_ok)(input),
4033            AMQPMethod::Rollback(ref rollback) => gen_rollback(rollback)(input),
4034            AMQPMethod::RollbackOk(ref rollback_ok) => gen_rollback_ok(rollback_ok)(input),
4035        })
4036    }
4037
4038    /// The available methods in tx
4039    #[derive(Clone, Debug, PartialEq)]
4040    pub enum AMQPMethod {
4041        /// select (Generated)
4042        Select(Select),
4043        /// select-ok (Generated)
4044        SelectOk(SelectOk),
4045        /// commit (Generated)
4046        Commit(Commit),
4047        /// commit-ok (Generated)
4048        CommitOk(CommitOk),
4049        /// rollback (Generated)
4050        Rollback(Rollback),
4051        /// rollback-ok (Generated)
4052        RollbackOk(RollbackOk),
4053    }
4054
4055    /// select (Generated)
4056    #[derive(Clone, Debug, Default, PartialEq)]
4057    pub struct Select {}
4058
4059    impl Select {
4060        /// Get the AMQP class id for select (Generated)
4061        pub fn get_amqp_class_id(&self) -> Identifier {
4062            90
4063        }
4064
4065        /// Get the AMQP method id for select (Generated)
4066        pub fn get_amqp_method_id(&self) -> Identifier {
4067            10
4068        }
4069    }
4070
4071    /// Parse select (Generated)
4072    pub fn parse_select<I: ParsableInput>(i: I) -> ParserResult<I, Select> {
4073        Ok((i, Select {}))
4074    }
4075
4076    /// Serialize select (Generated)
4077    pub fn gen_select<'a, W: Write + BackToTheBuffer + 'a>(
4078        _: &'a Select,
4079    ) -> impl SerializeFn<W> + 'a {
4080        move |mut input| {
4081            input = gen_id(10)(input)?;
4082            Ok(input)
4083        }
4084    }
4085    /// select-ok (Generated)
4086    #[derive(Clone, Debug, Default, PartialEq)]
4087    pub struct SelectOk {}
4088
4089    impl SelectOk {
4090        /// Get the AMQP class id for select-ok (Generated)
4091        pub fn get_amqp_class_id(&self) -> Identifier {
4092            90
4093        }
4094
4095        /// Get the AMQP method id for select-ok (Generated)
4096        pub fn get_amqp_method_id(&self) -> Identifier {
4097            11
4098        }
4099    }
4100
4101    /// Parse select-ok (Generated)
4102    pub fn parse_select_ok<I: ParsableInput>(i: I) -> ParserResult<I, SelectOk> {
4103        Ok((i, SelectOk {}))
4104    }
4105
4106    /// Serialize select-ok (Generated)
4107    pub fn gen_select_ok<'a, W: Write + BackToTheBuffer + 'a>(
4108        _: &'a SelectOk,
4109    ) -> impl SerializeFn<W> + 'a {
4110        move |mut input| {
4111            input = gen_id(11)(input)?;
4112            Ok(input)
4113        }
4114    }
4115    /// commit (Generated)
4116    #[derive(Clone, Debug, Default, PartialEq)]
4117    pub struct Commit {}
4118
4119    impl Commit {
4120        /// Get the AMQP class id for commit (Generated)
4121        pub fn get_amqp_class_id(&self) -> Identifier {
4122            90
4123        }
4124
4125        /// Get the AMQP method id for commit (Generated)
4126        pub fn get_amqp_method_id(&self) -> Identifier {
4127            20
4128        }
4129    }
4130
4131    /// Parse commit (Generated)
4132    pub fn parse_commit<I: ParsableInput>(i: I) -> ParserResult<I, Commit> {
4133        Ok((i, Commit {}))
4134    }
4135
4136    /// Serialize commit (Generated)
4137    pub fn gen_commit<'a, W: Write + BackToTheBuffer + 'a>(
4138        _: &'a Commit,
4139    ) -> impl SerializeFn<W> + 'a {
4140        move |mut input| {
4141            input = gen_id(20)(input)?;
4142            Ok(input)
4143        }
4144    }
4145    /// commit-ok (Generated)
4146    #[derive(Clone, Debug, Default, PartialEq)]
4147    pub struct CommitOk {}
4148
4149    impl CommitOk {
4150        /// Get the AMQP class id for commit-ok (Generated)
4151        pub fn get_amqp_class_id(&self) -> Identifier {
4152            90
4153        }
4154
4155        /// Get the AMQP method id for commit-ok (Generated)
4156        pub fn get_amqp_method_id(&self) -> Identifier {
4157            21
4158        }
4159    }
4160
4161    /// Parse commit-ok (Generated)
4162    pub fn parse_commit_ok<I: ParsableInput>(i: I) -> ParserResult<I, CommitOk> {
4163        Ok((i, CommitOk {}))
4164    }
4165
4166    /// Serialize commit-ok (Generated)
4167    pub fn gen_commit_ok<'a, W: Write + BackToTheBuffer + 'a>(
4168        _: &'a CommitOk,
4169    ) -> impl SerializeFn<W> + 'a {
4170        move |mut input| {
4171            input = gen_id(21)(input)?;
4172            Ok(input)
4173        }
4174    }
4175    /// rollback (Generated)
4176    #[derive(Clone, Debug, Default, PartialEq)]
4177    pub struct Rollback {}
4178
4179    impl Rollback {
4180        /// Get the AMQP class id for rollback (Generated)
4181        pub fn get_amqp_class_id(&self) -> Identifier {
4182            90
4183        }
4184
4185        /// Get the AMQP method id for rollback (Generated)
4186        pub fn get_amqp_method_id(&self) -> Identifier {
4187            30
4188        }
4189    }
4190
4191    /// Parse rollback (Generated)
4192    pub fn parse_rollback<I: ParsableInput>(i: I) -> ParserResult<I, Rollback> {
4193        Ok((i, Rollback {}))
4194    }
4195
4196    /// Serialize rollback (Generated)
4197    pub fn gen_rollback<'a, W: Write + BackToTheBuffer + 'a>(
4198        _: &'a Rollback,
4199    ) -> impl SerializeFn<W> + 'a {
4200        move |mut input| {
4201            input = gen_id(30)(input)?;
4202            Ok(input)
4203        }
4204    }
4205    /// rollback-ok (Generated)
4206    #[derive(Clone, Debug, Default, PartialEq)]
4207    pub struct RollbackOk {}
4208
4209    impl RollbackOk {
4210        /// Get the AMQP class id for rollback-ok (Generated)
4211        pub fn get_amqp_class_id(&self) -> Identifier {
4212            90
4213        }
4214
4215        /// Get the AMQP method id for rollback-ok (Generated)
4216        pub fn get_amqp_method_id(&self) -> Identifier {
4217            31
4218        }
4219    }
4220
4221    /// Parse rollback-ok (Generated)
4222    pub fn parse_rollback_ok<I: ParsableInput>(i: I) -> ParserResult<I, RollbackOk> {
4223        Ok((i, RollbackOk {}))
4224    }
4225
4226    /// Serialize rollback-ok (Generated)
4227    pub fn gen_rollback_ok<'a, W: Write + BackToTheBuffer + 'a>(
4228        _: &'a RollbackOk,
4229    ) -> impl SerializeFn<W> + 'a {
4230        move |mut input| {
4231            input = gen_id(31)(input)?;
4232            Ok(input)
4233        }
4234    }
4235}
4236/// confirm (generated)
4237pub mod confirm {
4238    use super::*;
4239
4240    /// Parse confirm (Generated)
4241    pub fn parse_confirm<I: ParsableInput>(i: I) -> ParserResult<I, confirm::AMQPMethod> {
4242        context(
4243            "parse_confirm",
4244            map_opt(
4245                flat_map(parse_id, |id| {
4246                    move |i| match id {
4247                        10 => context(
4248                            "parse_select",
4249                            map(map(parse_select, AMQPMethod::Select), Some),
4250                        )
4251                        .parse(i),
4252                        11 => context(
4253                            "parse_select_ok",
4254                            map(map(parse_select_ok, AMQPMethod::SelectOk), Some),
4255                        )
4256                        .parse(i),
4257                        _ => Ok((i, None)),
4258                    }
4259                }),
4260                std::convert::identity,
4261            ),
4262        )
4263        .parse(i)
4264    }
4265
4266    /// Serialize confirm (Generated)
4267    pub fn gen_confirm<'a, W: Write + BackToTheBuffer + 'a>(
4268        method: &'a AMQPMethod,
4269    ) -> impl SerializeFn<W> + 'a {
4270        cookie_factory::sequence::pair(gen_id(85), move |input| match *method {
4271            AMQPMethod::Select(ref select) => gen_select(select)(input),
4272            AMQPMethod::SelectOk(ref select_ok) => gen_select_ok(select_ok)(input),
4273        })
4274    }
4275
4276    /// The available methods in confirm
4277    #[derive(Clone, Debug, PartialEq)]
4278    pub enum AMQPMethod {
4279        /// select (Generated)
4280        Select(Select),
4281        /// select-ok (Generated)
4282        SelectOk(SelectOk),
4283    }
4284
4285    /// select (Generated)
4286    #[derive(Clone, Debug, Default, PartialEq)]
4287    pub struct Select {
4288        /// nowait (Generated)
4289        pub nowait: Boolean,
4290    }
4291
4292    impl Select {
4293        /// Get the AMQP class id for select (Generated)
4294        pub fn get_amqp_class_id(&self) -> Identifier {
4295            85
4296        }
4297
4298        /// Get the AMQP method id for select (Generated)
4299        pub fn get_amqp_method_id(&self) -> Identifier {
4300            10
4301        }
4302    }
4303
4304    /// Parse select (Generated)
4305    pub fn parse_select<I: ParsableInput>(i: I) -> ParserResult<I, Select> {
4306        let (i, flags) = parse_flags(i, &["nowait"])?;
4307        Ok((
4308            i,
4309            Select {
4310                nowait: flags.get_flag("nowait").unwrap_or(false),
4311            },
4312        ))
4313    }
4314
4315    /// Serialize select (Generated)
4316    pub fn gen_select<'a, W: Write + BackToTheBuffer + 'a>(
4317        method: &'a Select,
4318    ) -> impl SerializeFn<W> + 'a {
4319        move |mut input| {
4320            let mut flags = AMQPFlags::default();
4321            flags.add_flag("nowait".to_string(), method.nowait);
4322            input = gen_id(10)(input)?;
4323            input = gen_flags(&flags)(input)?;
4324            Ok(input)
4325        }
4326    }
4327    /// select-ok (Generated)
4328    #[derive(Clone, Debug, Default, PartialEq)]
4329    pub struct SelectOk {}
4330
4331    impl SelectOk {
4332        /// Get the AMQP class id for select-ok (Generated)
4333        pub fn get_amqp_class_id(&self) -> Identifier {
4334            85
4335        }
4336
4337        /// Get the AMQP method id for select-ok (Generated)
4338        pub fn get_amqp_method_id(&self) -> Identifier {
4339            11
4340        }
4341    }
4342
4343    /// Parse select-ok (Generated)
4344    pub fn parse_select_ok<I: ParsableInput>(i: I) -> ParserResult<I, SelectOk> {
4345        Ok((i, SelectOk {}))
4346    }
4347
4348    /// Serialize select-ok (Generated)
4349    pub fn gen_select_ok<'a, W: Write + BackToTheBuffer + 'a>(
4350        _: &'a SelectOk,
4351    ) -> impl SerializeFn<W> + 'a {
4352        move |mut input| {
4353            input = gen_id(11)(input)?;
4354            Ok(input)
4355        }
4356    }
4357}