From 01f6ed8ad8b54cd527f14964bf9f9939d9d0c1b4 Mon Sep 17 00:00:00 2001 From: MedzikUser Date: Sun, 5 Jun 2022 23:13:14 +0200 Subject: [PATCH] `Client` change `async fn` to `fn`, because `async` is not used --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- plugin_test/src/lib.rs | 2 +- src/commands/help.rs | 1 - src/tcp/client.rs | 4 ++-- src/tcp/handle_connection.rs | 2 +- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 41789c5..479f646 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -297,9 +297,9 @@ checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" [[package]] name = "tokio" -version = "1.19.0" +version = "1.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f392c8f16bda3456c0b00c6de39cb100449b98de55ac41c6cdd2bfcf53a1245" +checksum = "95eec79ea28c00a365f539f1961e9278fbcaf81c0ff6aaf0e93c181352446948" dependencies = [ "num_cpus", "once_cell", diff --git a/Cargo.toml b/Cargo.toml index 2e50b6d..b548d16 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,4 +13,4 @@ clap = { version = "3.1.18", features = ["derive"] } libloading = "0.7.3" log = { version = "0.4.17", features = ["release_max_level_info", "max_level_trace"] } simple_logger = { version = "2.1.0", default-features = false, features = ["colors"] } -tokio = { version = "1.19.0", features = ["rt-multi-thread", "macros"] } +tokio = { version = "1.19.1", features = ["rt-multi-thread", "macros"] } diff --git a/plugin_test/src/lib.rs b/plugin_test/src/lib.rs index c13a3fe..f3c9d9c 100644 --- a/plugin_test/src/lib.rs +++ b/plugin_test/src/lib.rs @@ -28,7 +28,7 @@ impl Command for PluginTest { } async fn execute(&self, client: &mut Client, _args: Vec<&str>, _commands: &CommandManagerType) { - client.send("content").await.expect("send message") + client.send("content").expect("send message") } } diff --git a/src/commands/help.rs b/src/commands/help.rs index 57083da..52abc33 100644 --- a/src/commands/help.rs +++ b/src/commands/help.rs @@ -26,7 +26,6 @@ impl Command for CommandHelp { for command in command_manager.commands.iter() { client .send(&format!("{} - {}", command.name(), command.help())) - .await .expect("send message"); } } diff --git a/src/tcp/client.rs b/src/tcp/client.rs index be1404e..84d1b9a 100644 --- a/src/tcp/client.rs +++ b/src/tcp/client.rs @@ -16,7 +16,7 @@ impl Client { } /// Read message/buffer from Client - pub async fn read(&mut self) -> anyhow::Result { + pub fn read(&mut self) -> anyhow::Result { // allocate an empty buffer of length 1024 bytes let mut buf = [0; 1024]; @@ -30,7 +30,7 @@ impl Client { } /// Send message to Client - pub async fn send(&mut self, content: &str) -> io::Result<()> { + pub fn send(&mut self, content: &str) -> io::Result<()> { // add a new line at the end of the content let content = format!("{content}\n\r"); diff --git a/src/tcp/handle_connection.rs b/src/tcp/handle_connection.rs index 2b33c06..e1847fb 100644 --- a/src/tcp/handle_connection.rs +++ b/src/tcp/handle_connection.rs @@ -15,7 +15,7 @@ pub async fn handle_connection( loop { // read client message/buffer - let buf = client.read().await?; + let buf = client.read()?; // split message by whitespace let args: &Vec<&str> = &buf.split_ascii_whitespace().collect();