diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2021-12-10 16:51:20 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-12-10 16:51:20 +0100 |
commit | 3767ecd55bbfea76afc1ae80a0dc7911832a9aa1 (patch) | |
tree | ce6668e25748ab647ccbf183f164683e54abd6a3 | |
parent | 6bc7a060fd42c06b76406eb4e8976f449afb59c6 (diff) |
Move ReactorRequest/ReactorReply to Reactor module
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r-- | lib/src/reactor/ctrl.rs | 22 | ||||
-rw-r--r-- | lib/src/reactor/gossip.rs | 4 | ||||
-rw-r--r-- | lib/src/reactor/mod.rs | 22 |
3 files changed, 25 insertions, 23 deletions
diff --git a/lib/src/reactor/ctrl.rs b/lib/src/reactor/ctrl.rs index 92246a9..a745394 100644 --- a/lib/src/reactor/ctrl.rs +++ b/lib/src/reactor/ctrl.rs @@ -3,6 +3,9 @@ use std::fmt::Debug; use tokio::sync::mpsc::UnboundedSender as Sender; use tokio::sync::mpsc::UnboundedReceiver as Receiver; +use crate::reactor::ReactorReply; +use crate::reactor::ReactorRequest; + /// Type for sending messages to a reactor pub type ReactorSender<CustomRequest, CustomReply> = Sender<(ReactorRequest<CustomRequest>, ReplyChannel<CustomReply>)>; @@ -15,22 +18,3 @@ pub type ReplyChannel<CustomReply> = Sender<ReactorReply<CustomReply>>; pub type ReplyReceiver<CustomReply> = Receiver<ReactorReply<CustomReply>>; -/// Send control messages to the reactor -#[derive(Debug)] -pub enum ReactorRequest<CustomRequest: Debug + Send + Sync> { - /// check if the reactor still responds - Ping, - - /// Quit the reactor - Exit, - - Custom(CustomRequest), -} - -#[derive(Debug)] -pub enum ReactorReply<CustomReply: Debug + Send + Sync> { - Pong, - Exiting, - - Custom(CustomReply), -} diff --git a/lib/src/reactor/gossip.rs b/lib/src/reactor/gossip.rs index 998112f..ba950db 100644 --- a/lib/src/reactor/gossip.rs +++ b/lib/src/reactor/gossip.rs @@ -11,9 +11,9 @@ use tokio::sync::RwLock; use crate::profile::Profile; use crate::reactor::Reactor; +use crate::reactor::ReactorReply; +use crate::reactor::ReactorRequest; use crate::reactor::ctrl::ReactorReceiver; -use crate::reactor::ctrl::ReactorReply; -use crate::reactor::ctrl::ReactorRequest; use crate::reactor::ctrl::ReactorSender; use crate::reactor::ctrl::ReplyChannel; diff --git a/lib/src/reactor/mod.rs b/lib/src/reactor/mod.rs index b4aa597..9e22b1e 100644 --- a/lib/src/reactor/mod.rs +++ b/lib/src/reactor/mod.rs @@ -12,11 +12,29 @@ mod account; mod ctrl; pub use ctrl::ReactorReceiver; -pub use ctrl::ReactorReply; -pub use ctrl::ReactorRequest; pub use ctrl::ReactorSender; pub use ctrl::ReplyChannel; +/// Send control messages to the reactor +#[derive(Debug)] +pub enum ReactorRequest<CustomRequest: Debug + Send + Sync> { + /// check if the reactor still responds + Ping, + + /// Quit the reactor + Exit, + + Custom(CustomRequest), +} + +#[derive(Debug)] +pub enum ReactorReply<CustomReply: Debug + Send + Sync> { + Pong, + Exiting, + + Custom(CustomReply), +} + /// Reactor type, for running the application logic /// /// The Reactor runs the whole application logic, that is syncing with other devices, fetching and |