pub struct RawCommand { /* private fields */ }Expand description
Execute an arbitrary Redis command by name.
Use this for commands not covered by typed structs, custom modules, or commands added in newer Redis versions.
§Example
use redis_tower_commands::RawCommand;
use redis_tower_core::RedisConnection;
let mut conn = RedisConnection::connect("127.0.0.1:6379").await?;
let result = conn.execute(RawCommand::new("CUSTOM.CMD").arg("key").arg("val")).await?;Implementations§
Source§impl RawCommand
impl RawCommand
Sourcepub fn new(name: impl Into<String>) -> RawCommand
pub fn new(name: impl Into<String>) -> RawCommand
Create a new raw command with the given command name.
Sourcepub fn arg(self, arg: impl AsRef<[u8]>) -> RawCommand
pub fn arg(self, arg: impl AsRef<[u8]>) -> RawCommand
Append an argument to this command.
Sourcepub fn query<T>(self) -> TypedRawCommand<T>where
T: FromFrame,
pub fn query<T>(self) -> TypedRawCommand<T>where
T: FromFrame,
Decode this command’s reply into a typed value T instead of a raw Frame.
Returns a TypedRawCommand whose Response is T, so execute
yields a decoded value. T can be any type implementing
FromFrame: scalars, String, Bytes,
Option<T>, Vec<T>, tuples, and HashMap<K, V>.
§Example
use redis_tower_commands::RawCommand;
use redis_tower_core::RedisConnection;
let mut conn = RedisConnection::connect("127.0.0.1:6379").await?;
let count: i64 = conn.execute(RawCommand::new("SCARD").arg("s").query()).await?;
let members: Vec<String> =
conn.execute(RawCommand::new("SMEMBERS").arg("s").query()).await?;Trait Implementations§
Source§impl Clone for RawCommand
impl Clone for RawCommand
Source§fn clone(&self) -> RawCommand
fn clone(&self) -> RawCommand
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Command for RawCommand
impl Command for RawCommand
Source§fn parse_response(&self, frame: Frame) -> Result<Frame, RedisError>
fn parse_response(&self, frame: Frame) -> Result<Frame, RedisError>
Parse a RESP response frame into the typed response. Read more
Source§fn idempotent(&self) -> bool
fn idempotent(&self) -> bool
Whether this command is safe to retry on connection errors. Read more
Source§fn is_blocking(&self) -> bool
fn is_blocking(&self) -> bool
Whether this command blocks the connection until data is available or a
timeout elapses –
BLPOP, BRPOP, BLMOVE, BZPOPMIN/BZPOPMAX, and
XREAD/XREADGROUP with BLOCK. Read moreAuto Trait Implementations§
impl Freeze for RawCommand
impl RefUnwindSafe for RawCommand
impl Send for RawCommand
impl Sync for RawCommand
impl Unpin for RawCommand
impl UnsafeUnpin for RawCommand
impl UnwindSafe for RawCommand
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<C> RequestDeadline for Cwhere
C: Command,
impl<C> RequestDeadline for Cwhere
C: Command,
Source§fn request_deadline(&self) -> Option<Instant>
fn request_deadline(&self) -> Option<Instant>
Return the request’s absolute deadline, if it carries one.