summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2023-01-02 12:24:18 +0100
committerMatthias Beyer <mail@beyermatthias.de>2023-01-02 15:20:14 +0100
commitbe6f9a1e8fc649021dfcdc896645cc8af8d22d22 (patch)
treec0f8e34c2acfedb1f2d654b59021b4481b43d534
parent0da5d1ec7d8852d4c9c78ae40c18e880611d6ebe (diff)
Make ClientCommand take Vec
This is for removing the static lifetime, which makes using the interface easier. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--mqtt-tester/src/client_report.rs8
-rw-r--r--mqtt-tester/src/command.rs8
2 files changed, 9 insertions, 7 deletions
diff --git a/mqtt-tester/src/client_report.rs b/mqtt-tester/src/client_report.rs
index c020790..9d85caf 100644
--- a/mqtt-tester/src/client_report.rs
+++ b/mqtt-tester/src/client_report.rs
@@ -48,13 +48,13 @@ async fn check_invalid_utf8_is_rejected(client_exe_path: &Path) -> miette::Resul
.await
.map(crate::command::Command::new)?
.wait_for_write([
- crate::command::ClientCommand::Send(&[
+ crate::command::ClientCommand::Send(vec![
0b0010_0000, // CONNACK
0b0000_0010, // Remaining length
0b0000_0000, // No session present
0b0000_0000, // Connection accepted
]),
- crate::command::ClientCommand::Send(&[
+ crate::command::ClientCommand::Send(vec![
0b0011_0000, // PUBLISH packet, DUP = 0, QoS = 0, Retain = 0
0b0000_0111, // Length
// Now the variable header
@@ -95,13 +95,13 @@ async fn check_receiving_server_packet(client_exe_path: &Path) -> miette::Result
.await
.map(crate::command::Command::new)?
.wait_for_write([
- crate::command::ClientCommand::Send(&[
+ crate::command::ClientCommand::Send(vec![
0b0010_0000, // CONNACK
0b0000_0010, // Remaining length
0b0000_0000, // No session present
0b0000_0000, // Connection accepted
]),
- crate::command::ClientCommand::Send(&[
+ crate::command::ClientCommand::Send(vec![
0b1000_0010, // SUBSCRIBE packet
0b0000_1000, // Length
// Now the variable header
diff --git a/mqtt-tester/src/command.rs b/mqtt-tester/src/command.rs
index f872928..e63c7f2 100644
--- a/mqtt-tester/src/command.rs
+++ b/mqtt-tester/src/command.rs
@@ -13,8 +13,8 @@ pub struct Command {
}
pub enum ClientCommand {
- Send(&'static [u8]),
- WaitFor(&'static [u8]),
+ Send(Vec<u8>),
+ WaitFor(Vec<u8>),
WaitAndCheck(Box<dyn FnOnce(&[u8]) -> bool>),
}
@@ -37,7 +37,9 @@ impl Command {
for command in commands {
match command {
- ClientCommand::Send(bytes) => to_client.write_all(bytes).await.into_diagnostic()?,
+ ClientCommand::Send(bytes) => {
+ to_client.write_all(&bytes).await.into_diagnostic()?
+ }
ClientCommand::WaitFor(expected_bytes) => {
let mut buf = Vec::with_capacity(expected_bytes.len());
match tokio::time::timeout(