summaryrefslogtreecommitdiffstats
path: root/lib/src/reactor/mod.rs
blob: 5299851df3c077c8f590f7f2221b0dd06e01e380 (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
27
28
use std::sync::Arc;
use std::fmt::Debug;

use anyhow::Result;
use tokio::sync::RwLock;

use crate::profile::Profile;

mod gossip;
mod device;
mod account;
mod ctrl;

use ctrl::ReactorReceiver;

#[async_trait::async_trait]
pub trait Reactor {
    type Request: Debug + Send + Sync;
    type Reply: Debug + Send + Sync;

    async fn run(self) -> Result<()>;
}

pub trait ReactorBuilder {
    type Reactor: Reactor;

    fn build_with_receiver(self, rr: ReactorReceiver<<Self::Reactor as Reactor>::Request, <Self::Reactor as Reactor>::Reply>) -> Self::Reactor;
}