Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parsing: fixed parsing frames with attributes contained dashes #37

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions protocol/src/frame/parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,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 @@ -646,7 +646,7 @@ pub mod basic {
let (i, _) = parse_short_uint.parse(i)?;
let (i, queue) = parse_short_string.parse(i)?;
let (i, consumer_tag) = parse_short_string.parse(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.parse(i)?;
Ok((
i,
Expand Down Expand Up @@ -998,7 +998,7 @@ pub mod basic {
pub fn parse_get<I: ParsableInput>(i: I) -> ParserResult<I, Get> {
let (i, _) = parse_short_uint.parse(i)?;
let (i, queue) = parse_short_string.parse(i)?;
let (i, flags) = parse_flags(i, &["no-ack"])?;
let (i, flags) = parse_flags(i, &["no_ack"])?;
Ok((
i,
Get {
Expand Down Expand Up @@ -3040,7 +3040,7 @@ pub mod exchange {
let (i, kind) = parse_short_string.parse(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.parse(i)?;
Ok((
Expand Down Expand Up @@ -3135,7 +3135,7 @@ pub mod exchange {
pub fn parse_delete<I: ParsableInput>(i: I) -> ParserResult<I, Delete> {
let (i, _) = parse_short_uint.parse(i)?;
let (i, exchange) = parse_short_string.parse(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 @@ -3527,7 +3527,7 @@ pub mod queue {
let (i, queue) = parse_short_string.parse(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.parse(i)?;
Ok((
Expand Down Expand Up @@ -3820,7 +3820,7 @@ pub mod queue {
pub fn parse_delete<I: ParsableInput>(i: I) -> ParserResult<I, Delete> {
let (i, _) = parse_short_uint.parse(i)?;
let (i, queue) = parse_short_string.parse(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
Loading