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