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
2
pub async fn connect(options: &Options) -> Result<MultiplexedConnection, Box<dyn StdError>> {
13
2
    let conn = Client::open(options.url.as_str())?
14
2
        .get_multiplexed_async_connection()
15
11
        .await?;
16
2
    Ok(conn)
17
2
}