sylvia_iot_auth/models/redis/
conn.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::error::Error as StdError;

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

/// Redis connection options.
pub struct Options {
    /// Redis URL. Use `redis://:password@host:port` format.
    pub url: String,
}

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