diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2021-12-07 15:58:00 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-12-10 15:45:27 +0100 |
commit | cecb6a4f0ffc28143ac9d437048484c83a37d277 (patch) | |
tree | 64255c1d6b968956e8d865c3ce997af3a2120dfe | |
parent | 81ac4baec0746fd5df328e6af25d88c80c0fef4f (diff) |
Add submodules for behaviour-specific reactors
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r-- | lib/src/reactor/account.rs | 19 | ||||
-rw-r--r-- | lib/src/reactor/device.rs | 19 | ||||
-rw-r--r-- | lib/src/reactor/gossip.rs | 24 | ||||
-rw-r--r-- | lib/src/reactor/mod.rs | 15 |
4 files changed, 77 insertions, 0 deletions
diff --git a/lib/src/reactor/account.rs b/lib/src/reactor/account.rs new file mode 100644 index 0000000..c6be1ce --- /dev/null +++ b/lib/src/reactor/account.rs @@ -0,0 +1,19 @@ +//! Module for account handling (following accounts, caching account updates) using the gossip +//! module for the lower-level handling + +use std::sync::Arc; + +use anyhow::Result; +use tokio::sync::RwLock; + +use crate::profile::Profile; +use crate::reactor::gossip::GossipReactor; + +#[derive(Debug)] +pub struct AccountReactor(GossipReactor); + +impl AccountReactor { + pub(super) fn new(profile: Arc<RwLock<Profile>>) -> Self { + Self(GossipReactor::new(profile)) + } +} diff --git a/lib/src/reactor/device.rs b/lib/src/reactor/device.rs new file mode 100644 index 0000000..c013db6 --- /dev/null +++ b/lib/src/reactor/device.rs @@ -0,0 +1,19 @@ +//! Module for multi-device support functionality, +//! which uses the gossip module for the lower-level handling + +use std::sync::Arc; + +use anyhow::Result; +use tokio::sync::RwLock; + +use crate::profile::Profile; +use crate::reactor::gossip::GossipReactor; + +#[derive(Debug)] +pub struct DeviceReactor(GossipReactor); + +impl DeviceReactor { + pub(super) fn new(profile: Arc<RwLock<Profile>>) -> Self { + Self(GossipReactor::new(profile)) + } +} diff --git a/lib/src/reactor/gossip.rs b/lib/src/reactor/gossip.rs new file mode 100644 index 0000000..e695dac --- /dev/null +++ b/lib/src/reactor/gossip.rs @@ -0,0 +1,24 @@ +//! Low-level module for gossip'ing code +//! +//! This module implements the low-level gossiping functionality that other modules use to +//! implement actual behaviours on +//! + +use std::sync::Arc; + +use anyhow::Result; +use tokio::sync::RwLock; + +use crate::profile::Profile; + +#[derive(Debug)] +pub struct GossipReactor { + profile: Arc<RwLock<Profile>>, +} + +impl GossipReactor { + pub(super) fn new(profile: Arc<RwLock<Profile>>) -> Self { + Self { profile } + } +} + diff --git a/lib/src/reactor/mod.rs b/lib/src/reactor/mod.rs index 70088a3..d55f5c6 100644 --- a/lib/src/reactor/mod.rs +++ b/lib/src/reactor/mod.rs @@ -5,6 +5,10 @@ use tokio::sync::RwLock; use crate::profile::Profile; +mod gossip; +mod device; +mod account; + /// Reactor type, for running the application logic /// /// The Reactor runs the whole application logic, that is syncing with other devices, fetching and @@ -43,4 +47,15 @@ impl Reactor { } } + /// Run the reactor + /// + /// Starts all inner functionality and exposes things + /// + /// # Return + /// + /// Return types are WIP, as this must return "running" objects that can be communicated with + pub async fn run(self) -> Result<()> { + unimplemented!() + } + } |