Struct ConnectionHandler

Source
pub struct ConnectionHandler<N: TcpClientStack, P: Protocol>
where HelloCommand: Command<<P as Protocol>::FrameType>,
{ /* private fields */ }
Expand description

Connection handler for Redis client

While the Client is not Send, the connection handler is. The handler is designed with the approach that the creation of new clients is cheap. Thus, the use of short-lived clients in concurrent applications is not a problem.

Implementations§

Source§

impl<N: TcpClientStack> ConnectionHandler<N, Resp2>

Source

pub fn resp2(remote: SocketAddr) -> ConnectionHandler<N, Resp2>

Creates a new connection handler using RESP2 protocol

Source§

impl<N: TcpClientStack> ConnectionHandler<N, Resp3>

Source

pub fn resp3(remote: SocketAddr) -> ConnectionHandler<N, Resp3>

Creates a new connection handler using RESP3 protocol

Source§

impl<N: TcpClientStack, P: Protocol> ConnectionHandler<N, P>
where AuthCommand: Command<<P as Protocol>::FrameType>, HelloCommand: Command<<P as Protocol>::FrameType>, PingCommand: Command<<P as Protocol>::FrameType>, <P as Protocol>::FrameType: ToStringOption + From<CommandBuilder>,

Source

pub fn connect<'a, C: Clock>( &'a mut self, network: &'a mut N, clock: Option<&'a C>, ) -> Result<Client<'a, N, C, P>, ConnectionError>

Returns a Redis client. Caches the connection for future reuse. The client has the same lifetime as the network reference.

As the connection is cached, later calls are cheap. So a new client may be created when switching threads, RISC tasks, etc.

Authentication Authentication is done automatically when creating a new connection. So the caller can expect a already authenticated and read2use client

§Arguments
  • network: Mutable borrow of embedded-nal network stack
  • clock: Borrow of embedded-time clock

returns: Result<Client<N, C, P>, ConnectionError>

Source

pub fn disconnect(&mut self, network: &mut N)

Disconnects the connection

Source§

impl<N: TcpClientStack, P: Protocol> ConnectionHandler<N, P>
where HelloCommand: Command<<P as Protocol>::FrameType>,

Source

pub fn timeout(&mut self, timeout: Microseconds) -> &mut Self

Sets the max. duration waiting for Redis responses

Source

pub fn auth(&mut self, credentials: Credentials) -> &mut Self

Sets the authentication credentials

Source

pub fn use_ping(&mut self) -> &mut Self

Using PING command for testing connections

Source

pub fn memory(&mut self, parameters: MemoryParameters) -> &mut Self

Sets memory allocation parameters

Auto Trait Implementations§

§

impl<N, P> !Freeze for ConnectionHandler<N, P>

§

impl<N, P> !RefUnwindSafe for ConnectionHandler<N, P>

§

impl<N, P> !Send for ConnectionHandler<N, P>

§

impl<N, P> !Sync for ConnectionHandler<N, P>

§

impl<N, P> !Unpin for ConnectionHandler<N, P>

§

impl<N, P> !UnwindSafe for ConnectionHandler<N, 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

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>,

Source§

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.