blob: dc922d5c01fa236917191ff9d0f1eee0e7170ead (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
use std::{future::Future, pin::Pin};
use async_nats::Client;
use serde::Deserialize;
#[derive(Clone, Debug, Deserialize)]
pub struct NatsConfigurationClientCert {
pub cert: String,
pub key: String,
}
#[derive(Clone, Debug, Deserialize)]
pub struct NatsConfigurationTls {
pub mtu: Option<usize>,
}
#[derive(Clone, Debug, Deserialize)]
pub struct NatsConfiguration {
pub host: String,
}
impl From<NatsConfiguration> for Pin<Box<dyn Future<Output = anyhow::Result<Client>>>> {
fn from(value: NatsConfiguration) -> Self {
Box::pin(async move { Ok(async_nats::connect(value.host).await?) })
}
}
|