Skip to content

Commit

Permalink
parsing: fixed parsing frames with attributes contained dashes
Browse files Browse the repository at this point in the history
  • Loading branch information
cheshirskycode authored and Keruspe committed Sep 21, 2024
1 parent 0364d9c commit 1e1fb83
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
21 changes: 21 additions & 0 deletions protocol/src/frame/parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
}
12 changes: 6 additions & 6 deletions protocol/src/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -980,7 +980,7 @@ pub mod basic {
pub fn parse_get<I: ParsableInput>(i: I) -> ParserResult<I, Get> {
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 {
Expand Down Expand Up @@ -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((
Expand Down Expand Up @@ -3093,7 +3093,7 @@ pub mod exchange {
pub fn parse_delete<I: ParsableInput>(i: I) -> ParserResult<I, Delete> {
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 {
Expand Down Expand Up @@ -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((
Expand Down Expand Up @@ -3769,7 +3769,7 @@ pub mod queue {
pub fn parse_delete<I: ParsableInput>(i: I) -> ParserResult<I, Delete> {
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 {
Expand Down
2 changes: 1 addition & 1 deletion protocol/templates/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ~}}
Expand Down

0 comments on commit 1e1fb83

Please sign in to comment.