pub struct Client<'a, N: TcpClientStack, C: Clock, P: Protocol>
where HelloCommand: Command<<P as Protocol>::FrameType>,
{ /* private fields */ }
Expand description

Client to execute Redis commands

The functionality of the client is best explained by a command example.

Implementations§

source§

impl<'a, N: TcpClientStack, C: Clock, P: Protocol> Client<'a, N, C, P>
where AuthCommand: Command<<P as Protocol>::FrameType>, HelloCommand: Command<<P as Protocol>::FrameType>,

source

pub fn bgsave( &'a self, schedule: bool ) -> Result<Future<'a, N, C, P, BackgroundSaveCommand>, CommandErrors>
where <P as Protocol>::FrameType: From<CommandBuilder>,

Shorthand for BackgroundSaveCommand

source§

impl<'a, N: TcpClientStack, C: Clock, P: Protocol> Client<'a, N, C, P>
where AuthCommand: Command<<P as Protocol>::FrameType>, HelloCommand: Command<<P as Protocol>::FrameType>,

source

pub fn get<K>( &'a self, key: K ) -> Result<Future<'a, N, C, P, GetCommand>, CommandErrors>
where <P as Protocol>::FrameType: ToStringBytes + IsNullFrame + From<CommandBuilder>, Bytes: From<K>,

Shorthand for GetCommand

source§

impl<'a, N: TcpClientStack, C: Clock, P: Protocol> Client<'a, N, C, P>
where AuthCommand: Command<<P as Protocol>::FrameType>, HelloCommand: Command<<P as Protocol>::FrameType>,

source

pub fn hget<K, F>( &'a self, key: K, field: F ) -> Result<Future<'a, N, C, P, HashGetCommand>, CommandErrors>
where <P as Protocol>::FrameType: ToStringBytes + IsNullFrame + From<CommandBuilder>, Bytes: From<K> + From<F>,

Shorthand for HashGetCommand

source§

impl<'a, N: TcpClientStack, C: Clock, P: Protocol> Client<'a, N, C, P>
where AuthCommand: Command<<P as Protocol>::FrameType>, HelloCommand: Command<<P as Protocol>::FrameType>,

source

pub fn hgetall<K>( &'a self, key: K ) -> Result<Future<'a, N, C, P, HashGetAllCommand>, CommandErrors>
where <P as Protocol>::FrameType: ToBytesMap + From<CommandBuilder>, Bytes: From<K>,

Shorthand for HashGetAllCommand

source§

impl<'a, N: TcpClientStack, C: Clock, P: Protocol> Client<'a, N, C, P>
where AuthCommand: Command<<P as Protocol>::FrameType>, HelloCommand: Command<<P as Protocol>::FrameType>,

source

pub fn hset<K, F, V>( &'a self, key: K, field: F, value: V ) -> Result<Future<'a, N, C, P, HashSetCommand<1>>, CommandErrors>
where Bytes: From<K> + From<F> + From<V>, <P as Protocol>::FrameType: ToInteger + From<CommandBuilder>,

Shorthand for HashSetCommand For setting multiple fields, use HashSetCommand directly instead

source§

impl<'a, N: TcpClientStack, C: Clock, P: Protocol> Client<'a, N, C, P>
where AuthCommand: Command<<P as Protocol>::FrameType>, HelloCommand: Command<<P as Protocol>::FrameType>,

source

pub fn ping(&'a self) -> Result<Future<'a, N, C, P, PingCommand>, CommandErrors>
where <P as Protocol>::FrameType: ToStringOption + From<CommandBuilder>,

Shorthand for PingCommand

source§

impl<'a, N: TcpClientStack, C: Clock, P: Protocol> Client<'a, N, C, P>
where AuthCommand: Command<<P as Protocol>::FrameType>, HelloCommand: Command<<P as Protocol>::FrameType>,

source

pub fn publish<K, V>( &'a self, channel: K, message: V ) -> Result<Future<'a, N, C, P, PublishCommand>, CommandErrors>
where <P as Protocol>::FrameType: ToInteger + From<CommandBuilder>, Bytes: From<K> + From<V>,

Shorthand for PublishCommand

source§

impl<'a, N: TcpClientStack, C: Clock, P: Protocol> Client<'a, N, C, P>
where AuthCommand: Command<<P as Protocol>::FrameType>, HelloCommand: Command<<P as Protocol>::FrameType>,

source

pub fn set<K, V>( &'a self, key: K, value: V ) -> Result<Future<'a, N, C, P, SetCommand<ConfirmationResponse>>, CommandErrors>
where <P as Protocol>::FrameType: ToStringBytes + ToStringOption + IsNullFrame + From<CommandBuilder>, Bytes: From<K> + From<V>,

Shorthand for SetCommand For using options of SET command, use SetCommand directly instead

source§

impl<'a, N: TcpClientStack, C: Clock, P: Protocol> Client<'a, N, C, P>
where AuthCommand: Command<<P as Protocol>::FrameType>, HelloCommand: Command<<P as Protocol>::FrameType>,

source

pub fn send<Cmd>( &'a self, command: Cmd ) -> Result<Future<'_, N, C, P, Cmd>, CommandErrors>
where Cmd: Command<P::FrameType>,

Sends the given command non-blocking

source

pub fn subscribe<const L: usize>( self, channels: [Bytes; L] ) -> Result<Subscription<'a, N, C, P, L>, Error>
where <P as Protocol>::FrameType: ToPushMessage + From<CommandBuilder>,

Subscribes the given channels and returns a subscription client.

If the subscriptions fails, it’s recommended to close the connection, as a the state is undefined. A further reuse of the connection could cause subsequent errors

source

pub fn close(&self)

Waiting on any dropped futures to leave a clean state

source§

impl<'a, N: TcpClientStack, C: Clock> Client<'a, N, C, Resp3>

source

pub fn get_hello_response(&self) -> &HelloResponse

Returns the response to HELLO command executed during connection initialization [Client HELLO response]

Trait Implementations§

source§

impl<'a, N: TcpClientStack, C: Clock, P: Protocol> Debug for Client<'a, N, C, P>
where HelloCommand: Command<<P as Protocol>::FrameType>,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, N, C, P> !RefUnwindSafe for Client<'a, N, C, P>

§

impl<'a, N, C, P> !Send for Client<'a, N, C, P>

§

impl<'a, N, C, P> !Sync for Client<'a, N, C, P>

§

impl<'a, N, C, P> Unpin for Client<'a, N, C, P>
where P: Unpin, <P as Protocol>::FrameType: Unpin,

§

impl<'a, N, C, P> !UnwindSafe for Client<'a, N, C, P>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.