Connect in redis::cluster - Rust
Description: Implements the process of connecting to a Redis server and obtaining and configuring a connection handle.

Skip to main content

## Connect

# Trait Connect

Source

    pub trait Connect: Sized {
        // Required methods
        fn connect<T>(info: T, timeout: Option<Duration>) -> RedisResult<Self>
           where T: IntoConnectionInfo;
        fn send_packed_command(&mut self, cmd: &[u8]) -> RedisResult<()>;
        fn set_write_timeout(&self, dur: Option<Duration>) -> RedisResult<()>;
        fn set_read_timeout(&self, dur: Option<Duration>) -> RedisResult<()>;
        fn recv_response(&mut self) -> RedisResult<Value>;
    }

Available on crate feature `cluster` only.
Expand description

Implements the process of connecting to a Redis server and obtaining and configuring a connection handle.

## Required Methods§

Source

#### fn connect<T>(info: T, timeout: Option<Duration>) -> RedisResult<Self>
where T: IntoConnectionInfo,

Connect to a node, returning handle for command execution.

Source

#### fn send_packed_command(&mut self, cmd: &[u8]) -> RedisResult<()>

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.

Source

#### fn set_write_timeout(&self, dur: Option<Duration>) -> RedisResult<()>

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.

Source

#### fn set_read_timeout(&self, dur: Option<Duration>) -> RedisResult<()>

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.

Source

#### fn recv_response(&mut self) -> RedisResult<Value>

Fetches a single response from the connection. This is useful if used in combination with `send_packed_command`.

## Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

## Implementors§

Source§

### impl Connect for Connection