1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
use crate::{
resp::{FromValue, Value},
Command, Future,
};
pub trait CommandSend {
/// Send an arbitrary command to the server.
///
/// This is used primarily intended for implementing high level commands API
/// but may also be used to provide access to new features that lack a direct API.
///
/// # Arguments
/// * `name` - Command name in uppercase.
/// * `args` - Command arguments which can be provided as arrays (up to 4 elements) or vectors of [BulkString](crate::resp::BulkString).
///
/// # Example
/// ```ignore
/// let connection = ConnectionMultiplexer::connect("127.0.0.1:6379").await?;
/// let database = connection.get_default_database();
///
/// let values: Vec<String> = database
/// .send(cmd("MGET").arg("key1").arg("key2").arg("key3").arg("key4"))
/// .await?
/// .into()?;
/// ```
fn send(&self, command: Command) -> Future<'_, Value>;
fn send_into<T: FromValue>(&self, command: Command) -> Future<'_, T> {
let fut = self.send(command);
Box::pin(async move { fut.await?.into() })
}
}