[−][src]Struct redis::Connection
Represents a stateful redis TCP connection.
Methods
impl Connection
[src]
A connection is an object that represents a single redis connection. It provides basic support for sending encoded commands into a redis connection and to read a response from it. It's bound to a single database and can only be created from the client.
You generally do not much with this object other than passing it to
Cmd
objects.
pub fn send_packed_command(&mut self, cmd: &[u8]) -> RedisResult<()>
[src]
Sends an already encoded (packed) command into the TCP socket and
does not read a response. This is useful for commands like
MONITOR
which yield multiple items. This needs to be used with
care because it changes the state of the connection.
pub fn recv_response(&mut self) -> RedisResult<Value>
[src]
Fetches a single response from the connection. This is useful
if used in combination with send_packed_command
.
pub fn set_write_timeout(&self, dur: Option<Duration>) -> RedisResult<()>
[src]
Sets the write timeout for the connection.
If the provided value is None
, then send_packed_command
call will
block indefinitely. It is an error to pass the zero Duration
to this
method.
pub fn set_read_timeout(&self, dur: Option<Duration>) -> RedisResult<()>
[src]
Sets the read timeout for the connection.
If the provided value is None
, then recv_response
call will
block indefinitely. It is an error to pass the zero Duration
to this
method.
pub fn as_pubsub<'a>(&'a mut self) -> PubSub<'a>
[src]
pub fn is_open(&self) -> bool
[src]
Returns the connection status.
The connection is open until any read_response
call recieved an
invalid response from the server (most likely a closed or dropped
connection, otherwise a Redis protocol error). When using unix
sockets the connection is open until writing a command failed with a
BrokenPipe
error.
Trait Implementations
impl PubSubCommands for Connection
[src]
fn subscribe<'a, C, F, U>(&mut self, channels: C, func: F) -> RedisResult<U> where
F: FnMut(Msg) -> ControlFlow<U>,
C: ToRedisArgs,
[src]
F: FnMut(Msg) -> ControlFlow<U>,
C: ToRedisArgs,
fn psubscribe<'a, P, F, U>(&mut self, patterns: P, func: F) -> RedisResult<U> where
F: FnMut(Msg) -> ControlFlow<U>,
P: ToRedisArgs,
[src]
F: FnMut(Msg) -> ControlFlow<U>,
P: ToRedisArgs,
impl ConnectionLike for Connection
[src]
fn req_packed_command(&mut self, cmd: &[u8]) -> RedisResult<Value>
[src]
fn req_packed_commands(
&mut self,
cmd: &[u8],
offset: usize,
count: usize
) -> RedisResult<Vec<Value>>
[src]
&mut self,
cmd: &[u8],
offset: usize,
count: usize
) -> RedisResult<Vec<Value>>
fn get_db(&self) -> i64
[src]
Auto Trait Implementations
impl Send for Connection
impl Sync for Connection
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,