summaryrefslogtreecommitdiff
path: root/libs/shared/src/redis.rs
diff options
context:
space:
mode:
authorMatthieuCoder <matthieu@matthieu-dev.xyz>2023-01-18 16:03:11 +0400
committerMatthieuCoder <matthieu@matthieu-dev.xyz>2023-01-18 16:03:11 +0400
commit7f4406d0946d409a842b4b364541380e50d92010 (patch)
tree1fecd2717a09bc3256822c1f0a0617f1d4abe272 /libs/shared/src/redis.rs
parentcbaa1665485b0d5fc52a54ff15a5e4b491e3c671 (diff)
base
Diffstat (limited to 'libs/shared/src/redis.rs')
-rw-r--r--libs/shared/src/redis.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/libs/shared/src/redis.rs b/libs/shared/src/redis.rs
index 77aa97f..5cae869 100644
--- a/libs/shared/src/redis.rs
+++ b/libs/shared/src/redis.rs
@@ -1,18 +1,22 @@
use redis::{aio::MultiplexedConnection, Client};
use serde::Deserialize;
-use std::{future::Future, pin::Pin};
+use std::{
+ future::{Future, IntoFuture},
+ pin::Pin,
+};
#[derive(Clone, Debug, Deserialize)]
pub struct Configuration {
pub url: String,
}
-impl From<Configuration>
- for Pin<Box<dyn Future<Output = anyhow::Result<MultiplexedConnection>> + Send>>
-{
- fn from(value: Configuration) -> Self {
+impl IntoFuture for Configuration {
+ type Output = anyhow::Result<MultiplexedConnection>;
+ type IntoFuture = Pin<Box<dyn Future<Output = Self::Output> + Send>>;
+
+ fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
- let con = Client::open(value.url)?;
+ let con = Client::open(self.url)?;
let (multiplex, ready) = con.create_multiplexed_tokio_connection().await?;
tokio::spawn(ready);