1
use std::error::Error as StdError;
2

            
3
use redis::{aio::MultiplexedConnection, Client};
4

            
5
/// Redis connection options.
6
pub struct Options {
7
    /// Redis URL. Use `redis://:password@host:port` format.
8
    pub url: String,
9
}
10

            
11
/// Connect to Redis.
12
4
pub async fn connect(options: &Options) -> Result<MultiplexedConnection, Box<dyn StdError>> {
13
4
    let conn = Client::open(options.url.as_str())?
14
4
        .get_multiplexed_async_connection()
15
4
        .await?;
16
4
    Ok(conn)
17
4
}