From 1e1fb839a8d07812e979d0eaa86fc36d772ef8ce Mon Sep 17 00:00:00 2001 From: Michael Zhalevich Date: Tue, 17 Sep 2024 15:36:55 +0200 Subject: [PATCH 1/2] parsing: fixed parsing frames with attributes contained dashes --- protocol/src/frame/parsing.rs | 21 +++++++++++++++++++++ protocol/src/generated.rs | 12 ++++++------ protocol/templates/protocol.rs | 2 +- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/protocol/src/frame/parsing.rs b/protocol/src/frame/parsing.rs index 4f9a189..b5548c5 100644 --- a/protocol/src/frame/parsing.rs +++ b/protocol/src/frame/parsing.rs @@ -157,4 +157,25 @@ mod test { Ok((&[][..], AMQPFrame::Heartbeat(1))) ); } + + #[test] + fn test_parse_declare_queue_frame() { + let frame = AMQPFrame::Method( + 1, + AMQPClass::Queue(queue::AMQPMethod::Declare(queue::Declare { + queue: "some_queue".into(), + passive: true, + durable: true, + exclusive: true, + auto_delete: true, + nowait: true, + arguments: Default::default(), + })), + ); + + let mut buffer = vec![0u8; 30]; + + assert!(gen_frame(&frame)(buffer.as_mut_slice().into()).is_ok()); + assert_eq!(parse_frame(buffer.as_slice()), Ok((&[][..], frame))); + } } diff --git a/protocol/src/generated.rs b/protocol/src/generated.rs index b3c1fbc..cb5ccc1 100644 --- a/protocol/src/generated.rs +++ b/protocol/src/generated.rs @@ -628,7 +628,7 @@ pub mod basic { let (i, _) = parse_short_uint(i)?; let (i, queue) = parse_short_string(i)?; let (i, consumer_tag) = parse_short_string(i)?; - let (i, flags) = parse_flags(i, &["no-local", "no-ack", "exclusive", "nowait"])?; + let (i, flags) = parse_flags(i, &["no_local", "no_ack", "exclusive", "nowait"])?; let (i, arguments) = parse_field_table(i)?; Ok(( i, @@ -980,7 +980,7 @@ pub mod basic { pub fn parse_get(i: I) -> ParserResult { let (i, _) = parse_short_uint(i)?; let (i, queue) = parse_short_string(i)?; - let (i, flags) = parse_flags(i, &["no-ack"])?; + let (i, flags) = parse_flags(i, &["no_ack"])?; Ok(( i, Get { @@ -2998,7 +2998,7 @@ pub mod exchange { let (i, kind) = parse_short_string(i)?; let (i, flags) = parse_flags( i, - &["passive", "durable", "auto-delete", "internal", "nowait"], + &["passive", "durable", "auto_delete", "internal", "nowait"], )?; let (i, arguments) = parse_field_table(i)?; Ok(( @@ -3093,7 +3093,7 @@ pub mod exchange { pub fn parse_delete(i: I) -> ParserResult { let (i, _) = parse_short_uint(i)?; let (i, exchange) = parse_short_string(i)?; - let (i, flags) = parse_flags(i, &["if-unused", "nowait"])?; + let (i, flags) = parse_flags(i, &["if_unused", "nowait"])?; Ok(( i, Delete { @@ -3476,7 +3476,7 @@ pub mod queue { let (i, queue) = parse_short_string(i)?; let (i, flags) = parse_flags( i, - &["passive", "durable", "exclusive", "auto-delete", "nowait"], + &["passive", "durable", "exclusive", "auto_delete", "nowait"], )?; let (i, arguments) = parse_field_table(i)?; Ok(( @@ -3769,7 +3769,7 @@ pub mod queue { pub fn parse_delete(i: I) -> ParserResult { let (i, _) = parse_short_uint(i)?; let (i, queue) = parse_short_string(i)?; - let (i, flags) = parse_flags(i, &["if-unused", "if-empty", "nowait"])?; + let (i, flags) = parse_flags(i, &["if_unused", "if_empty", "nowait"])?; Ok(( i, Delete { diff --git a/protocol/templates/protocol.rs b/protocol/templates/protocol.rs index 254cd45..4ca157a 100644 --- a/protocol/templates/protocol.rs +++ b/protocol/templates/protocol.rs @@ -241,7 +241,7 @@ pub mod {{snake class.name}} { {{else}} let (i, {{#if argument.ignore_flags ~}}_{{else}}flags{{/if ~}}) = parse_flags(i, &[ {{#each argument.flags as |flag| ~}} - "{{flag.name}}", + "{{snake flag.name}}", {{/each ~}} ])?; {{/if ~}} From 9a4e7ee97234dd876087ac46657a3dfe4625d681 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Perennou Date: Sat, 21 Sep 2024 14:00:08 +0200 Subject: [PATCH 2/2] v7.2.2 Signed-off-by: Marc-Antoine Perennou --- codegen/Cargo.toml | 4 ++-- protocol/Cargo.toml | 10 +++++----- tcp/Cargo.toml | 4 ++-- types/Cargo.toml | 2 +- uri/Cargo.toml | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/codegen/Cargo.toml b/codegen/Cargo.toml index 8fedb8e..8093567 100644 --- a/codegen/Cargo.toml +++ b/codegen/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "amq-protocol-codegen" -version = "7.2.1" +version = "7.2.2" edition = "2021" authors = ["Marc-Antoine Perennou <%arc-Antoine@Perennou.com>"] description = "AMQP specifications - codegen" @@ -19,7 +19,7 @@ handlebars = "^5.0" serde_json = "^1.0" [dependencies.amq-protocol-types] -version = "=7.2.1" +version = "=7.2.2" path = "../types" [dependencies.serde] diff --git a/protocol/Cargo.toml b/protocol/Cargo.toml index 432118f..0bf47aa 100644 --- a/protocol/Cargo.toml +++ b/protocol/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "amq-protocol" -version = "7.2.1" +version = "7.2.2" edition = "2021" authors = ["Marc-Antoine Perennou <%arc-Antoine@Perennou.com>"] description = "AMQP specifications" @@ -28,21 +28,21 @@ vendored-openssl = ["amq-protocol-tcp/vendored-openssl"] verbose-errors = ["amq-protocol-types/verbose-errors"] [build-dependencies.amq-protocol-codegen] -version = "=7.2.1" +version = "=7.2.2" path = "../codegen" optional = true [dependencies.amq-protocol-tcp] -version = "=7.2.1" +version = "=7.2.2" default-features = false path = "../tcp" [dependencies.amq-protocol-types] -version = "=7.2.1" +version = "=7.2.2" path = "../types" [dependencies.amq-protocol-uri] -version = "=7.2.1" +version = "=7.2.2" path = "../uri" [dependencies.cookie-factory] diff --git a/tcp/Cargo.toml b/tcp/Cargo.toml index 1917804..abd3e14 100644 --- a/tcp/Cargo.toml +++ b/tcp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "amq-protocol-tcp" -version = "7.2.1" +version = "7.2.2" edition = "2021" authors = ["Marc-Antoine Perennou <%arc-Antoine@Perennou.com>"] description = "AMQP URI TCP connection handling" @@ -25,7 +25,7 @@ rustls-connector = ["tcp-stream/rustls-connector"] vendored-openssl = ["tcp-stream/vendored-openssl"] [dependencies.amq-protocol-uri] -version = "=7.2.1" +version = "=7.2.2" path = "../uri" [dependencies.tcp-stream] diff --git a/types/Cargo.toml b/types/Cargo.toml index d70cf44..976a95c 100644 --- a/types/Cargo.toml +++ b/types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "amq-protocol-types" -version = "7.2.1" +version = "7.2.2" edition = "2021" authors = ["Marc-Antoine Perennou <%arc-Antoine@Perennou.com>"] description = "AMQP specifications - types" diff --git a/uri/Cargo.toml b/uri/Cargo.toml index 8740f72..7572ea7 100644 --- a/uri/Cargo.toml +++ b/uri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "amq-protocol-uri" -version = "7.2.1" +version = "7.2.2" edition = "2021" authors = ["Marc-Antoine Perennou <%arc-Antoine@Perennou.com>"] description = "AMQP URI manipulation" @@ -15,7 +15,7 @@ rust-version = "1.63.0" name = "amq_protocol_uri" [dependencies.amq-protocol-types] -version = "=7.2.1" +version = "=7.2.2" path = "../types" [dependencies]