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>
impl<N: TcpClientStack> ConnectionHandler<N, Resp2>
Sourcepub fn resp2(remote: SocketAddr) -> ConnectionHandler<N, Resp2>
pub fn resp2(remote: SocketAddr) -> ConnectionHandler<N, Resp2>
Creates a new connection handler using RESP2 protocol
Source§impl<N: TcpClientStack> ConnectionHandler<N, Resp3>
impl<N: TcpClientStack> ConnectionHandler<N, Resp3>
Sourcepub fn resp3(remote: SocketAddr) -> ConnectionHandler<N, Resp3>
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>,
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>,
Sourcepub fn connect<'a, C: Clock>(
&'a mut self,
network: &'a mut N,
clock: Option<&'a C>,
) -> Result<Client<'a, N, C, P>, ConnectionError>
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 stackclock
: Borrow of embedded-time clock
returns: Result<Client<N, C, P>, ConnectionError>
Sourcepub fn disconnect(&mut self, network: &mut N)
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>,
impl<N: TcpClientStack, P: Protocol> ConnectionHandler<N, P>where
HelloCommand: Command<<P as Protocol>::FrameType>,
Sourcepub fn timeout(&mut self, timeout: Microseconds) -> &mut Self
pub fn timeout(&mut self, timeout: Microseconds) -> &mut Self
Sets the max. duration waiting for Redis responses
Sourcepub fn auth(&mut self, credentials: Credentials) -> &mut Self
pub fn auth(&mut self, credentials: Credentials) -> &mut Self
Sets the authentication credentials
Sourcepub fn memory(&mut self, parameters: MemoryParameters) -> &mut Self
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> 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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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