pub struct CommandArg(/* private fields */);Expand description
An owned, binary-safe Redis command argument.
Redis keys, values, fields, and members are byte strings, not UTF-8 text.
CommandArg lets typed command builders accept those bytes without giving
up the convenient string call sites used by most applications.
Owned String, Vec<u8>, and Bytes inputs reuse their allocation
(or shared storage). Borrowed strings, byte slices, and arrays are copied
once because command values must be owned and may outlive the caller.
Cloning a CommandArg is cheap because Bytes uses shared storage.
§Examples
use bytes::Bytes;
use redis_tower_commands::CommandArg;
let text = CommandArg::from("users:42");
let invalid_utf8 = CommandArg::from(&b"key:\xff"[..]);
let shared = CommandArg::from(Bytes::from_static(b"payload"));
assert_eq!(text.as_bytes(), b"users:42");
assert_eq!(invalid_utf8.as_bytes(), b"key:\xff");
assert_eq!(shared.as_bytes(), b"payload");Implementations§
Source§impl CommandArg
impl CommandArg
Sourcepub fn copy_from_slice(value: &[u8]) -> CommandArg
pub fn copy_from_slice(value: &[u8]) -> CommandArg
Construct an argument by copying a borrowed byte slice.
Sourcepub const fn from_static(value: &'static [u8]) -> CommandArg
pub const fn from_static(value: &'static [u8]) -> CommandArg
Construct an argument backed by static bytes without copying.
Sourcepub fn into_bytes(self) -> Bytes
pub fn into_bytes(self) -> Bytes
Consume the argument and return its shared byte storage.
Trait Implementations§
Source§impl AsRef<[u8]> for CommandArg
impl AsRef<[u8]> for CommandArg
Source§impl Clone for CommandArg
impl Clone for CommandArg
Source§fn clone(&self) -> CommandArg
fn clone(&self) -> CommandArg
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 Debug for CommandArg
impl Debug for CommandArg
Source§impl Default for CommandArg
impl Default for CommandArg
Source§fn default() -> CommandArg
fn default() -> CommandArg
Returns the “default value” for a type. Read more
impl Eq for CommandArg
Source§impl From<&&[u8]> for CommandArg
impl From<&&[u8]> for CommandArg
Source§fn from(value: &&[u8]) -> CommandArg
fn from(value: &&[u8]) -> CommandArg
Converts to this type from the input type.
Source§impl From<&&str> for CommandArg
impl From<&&str> for CommandArg
Source§fn from(value: &&str) -> CommandArg
fn from(value: &&str) -> CommandArg
Converts to this type from the input type.
Source§impl From<&Bytes> for CommandArg
impl From<&Bytes> for CommandArg
Source§fn from(value: &Bytes) -> CommandArg
fn from(value: &Bytes) -> CommandArg
Converts to this type from the input type.
Source§impl From<&CommandArg> for CommandArg
impl From<&CommandArg> for CommandArg
Source§fn from(value: &CommandArg) -> CommandArg
fn from(value: &CommandArg) -> CommandArg
Converts to this type from the input type.
Source§impl From<&String> for CommandArg
impl From<&String> for CommandArg
Source§fn from(value: &String) -> CommandArg
fn from(value: &String) -> CommandArg
Converts to this type from the input type.
Source§impl From<&[u8]> for CommandArg
impl From<&[u8]> for CommandArg
Source§fn from(value: &[u8]) -> CommandArg
fn from(value: &[u8]) -> CommandArg
Converts to this type from the input type.
Source§impl From<&mut str> for CommandArg
impl From<&mut str> for CommandArg
Source§fn from(value: &mut str) -> CommandArg
fn from(value: &mut str) -> CommandArg
Converts to this type from the input type.
Source§impl From<&str> for CommandArg
impl From<&str> for CommandArg
Source§fn from(value: &str) -> CommandArg
fn from(value: &str) -> CommandArg
Converts to this type from the input type.
Source§impl From<Bytes> for CommandArg
impl From<Bytes> for CommandArg
Source§fn from(value: Bytes) -> CommandArg
fn from(value: Bytes) -> CommandArg
Converts to this type from the input type.
Source§impl From<String> for CommandArg
impl From<String> for CommandArg
Source§fn from(value: String) -> CommandArg
fn from(value: String) -> CommandArg
Converts to this type from the input type.
Source§impl From<char> for CommandArg
impl From<char> for CommandArg
Source§fn from(value: char) -> CommandArg
fn from(value: char) -> CommandArg
Converts to this type from the input type.
Source§impl Hash for CommandArg
impl Hash for CommandArg
Source§impl Ord for CommandArg
impl Ord for CommandArg
Source§fn cmp(&self, other: &CommandArg) -> Ordering
fn cmp(&self, other: &CommandArg) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialEq for CommandArg
impl PartialEq for CommandArg
Source§impl PartialOrd for CommandArg
impl PartialOrd for CommandArg
impl StructuralPartialEq for CommandArg
Auto Trait Implementations§
impl !Freeze for CommandArg
impl RefUnwindSafe for CommandArg
impl Send for CommandArg
impl Sync for CommandArg
impl Unpin for CommandArg
impl UnsafeUnpin for CommandArg
impl UnwindSafe for CommandArg
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<T> ToHex for T
impl<T> ToHex for T
Source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self into the result. Lower case
letters are used (e.g. f9b4ca)Source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self into the result. Upper case
letters are used (e.g. F9B4CA)