From 66bcf2518db8cad0b078df96ba412da4aec900be Mon Sep 17 00:00:00 2001 From: ArtemIsmagilov Date: Tue, 24 Dec 2024 22:03:37 +0400 Subject: [PATCH] add high level module help --- src/commands/server_commands.rs | 33 +++++++++++++++++++++++++++++++++ src/tests/server_commands.rs | 12 ++++++++++++ 2 files changed, 45 insertions(+) diff --git a/src/commands/server_commands.rs b/src/commands/server_commands.rs index cc33241..9d48b0e 100644 --- a/src/commands/server_commands.rs +++ b/src/commands/server_commands.rs @@ -914,6 +914,39 @@ pub trait ServerCommands<'a> { prepare_command(self, cmd("MODULE").arg("LIST")) } + /// The command returns a helpful text describing the different MODULE subcommands. + /// + /// # Return + /// An array of strings. + /// + /// # Example + /// ``` + /// # use rustis::{ + /// # client::Client, + /// # commands::ServerCommands, + /// # Result, + /// # }; + /// # + /// # #[cfg_attr(feature = "tokio-runtime", tokio::main)] + /// # #[cfg_attr(feature = "async-std-runtime", async_std::main)] + /// # async fn main() -> Result<()> { + /// # let client = Client::connect("127.0.0.1:6379").await?; + /// let result: Vec = client.module_help().await?; + /// assert!(result.iter().any(|e| e == "HELP")); + /// # Ok(()) + /// # } + /// ``` + /// + /// # See Also + /// [](https://redis.io/commands/module-help/) + #[must_use] + fn module_help(self) -> PreparedCommand<'a, Self, Vec> + where + Self: Sized, + { + prepare_command(self, cmd("MODULE").arg("HELP")) + } + /// Loads a module from a dynamic library at runtime. /// /// # See Also diff --git a/src/tests/server_commands.rs b/src/tests/server_commands.rs index 0df2dab..0ae25bb 100644 --- a/src/tests/server_commands.rs +++ b/src/tests/server_commands.rs @@ -915,6 +915,18 @@ async fn memory_usage() -> Result<()> { Ok(()) } +#[cfg_attr(feature = "tokio-runtime", tokio::test)] +#[cfg_attr(feature = "async-std-runtime", async_std::test)] +#[serial] +async fn module_help() -> Result<()> { + let client = get_test_client().await?; + + let result: Vec = client.module_help().await?; + assert!(result.iter().any(|e| e == "HELP")); + + Ok(()) +} + #[cfg_attr(feature = "tokio-runtime", tokio::test)] #[cfg_attr(feature = "async-std-runtime", async_std::test)] #[serial]