diff --git a/src/commands/server_commands.rs b/src/commands/server_commands.rs index bd99e3f..1d4df75 100644 --- a/src/commands/server_commands.rs +++ b/src/commands/server_commands.rs @@ -122,6 +122,38 @@ pub trait ServerCommands<'a> { prepare_command(self, cmd("ACL").arg("GETUSER").arg(username)) } + /// The command returns a helpful text describing the different ACL subcommands. + /// + /// # Return + /// An array of strings. + /// + /// # Example + /// ``` + /// # use rustis::{ + /// # client::{Client, ClientPreparedCommand}, + /// # commands::{FlushingMode, GetExOptions, GenericCommands, ServerCommands, StringCommands}, + /// # resp::cmd, + /// # 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.acl_help().await?; + /// assert!(result.iter().any(|e| e == "HELP")); + /// # Ok(()) + /// # } + /// ``` + /// # See Also + /// [](https://redis.io/commands/acl-help/) + fn acl_help(self) -> PreparedCommand<'a, Self, Vec> + where + Self: Sized, + { + prepare_command(self, cmd("ACL").arg("HELP")) + } + /// The command shows the currently active ACL rules in the Redis server. /// /// # Return @@ -864,8 +896,7 @@ pub enum FlushingMode { impl ToArgs for FlushingMode { fn write_args(&self, args: &mut CommandArgs) { match self { - FlushingMode::Default => { - } + FlushingMode::Default => {} FlushingMode::Async => { args.arg("ASYNC"); } @@ -1928,10 +1959,12 @@ impl<'de> Deserialize<'de> for RoleResult { match role { "master" => { - let Some(master_replication_offset): Option = seq.next_element()? else { + let Some(master_replication_offset): Option = seq.next_element()? + else { return Err(de::Error::invalid_length(1, &"more elements in sequence")); }; - let Some(replica_infos): Option> = seq.next_element()? else { + let Some(replica_infos): Option> = seq.next_element()? + else { return Err(de::Error::invalid_length(2, &"more elements in sequence")); }; Ok(RoleResult::Master { diff --git a/src/tests/server_commands.rs b/src/tests/server_commands.rs index a37536f..d4dad4d 100644 --- a/src/tests/server_commands.rs +++ b/src/tests/server_commands.rs @@ -9,7 +9,9 @@ use crate::{ }, resp::{cmd, Value}, spawn, - tests::{get_default_config, get_sentinel_test_client, get_test_client, get_test_client_with_config}, + tests::{ + get_default_config, get_sentinel_test_client, get_test_client, get_test_client_with_config, + }, Error, RedisError, RedisErrorKind, Result, }; use futures_util::StreamExt; @@ -118,6 +120,18 @@ async fn acl_getuser() -> Result<()> { Ok(()) } +#[cfg_attr(feature = "tokio-runtime", tokio::test)] +#[cfg_attr(feature = "async-std-runtime", async_std::test)] +#[serial] +async fn acl_help() -> Result<()> { + let client = get_test_client().await?; + + let result: Vec = client.acl_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]