aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/rbw-agent/agent.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/rbw-agent/agent.rs')
-rw-r--r--src/bin/rbw-agent/agent.rs44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/bin/rbw-agent/agent.rs b/src/bin/rbw-agent/agent.rs
index b88121d..d4b3341 100644
--- a/src/bin/rbw-agent/agent.rs
+++ b/src/bin/rbw-agent/agent.rs
@@ -1,4 +1,3 @@
-use aes::cipher::typenum::private::IsNotEqualPrivate;
use anyhow::Context as _;
use futures_util::StreamExt as _;
@@ -12,7 +11,7 @@ pub struct State {
pub timeout_duration: std::time::Duration,
pub sync_timeout: crate::timeout::Timeout,
pub sync_timeout_duration: std::time::Duration,
- pub notifications_handler: crate::notifications::NotificationsHandler,
+ pub notifications_handler: crate::notifications::Handler,
}
impl State {
@@ -59,8 +58,7 @@ impl Agent {
if sync_timeout_duration > std::time::Duration::ZERO {
sync_timeout.set(sync_timeout_duration);
}
- let notifications_handler =
- crate::notifications::NotificationsHandler::new();
+ let notifications_handler = crate::notifications::Handler::new();
Ok(Self {
timer_r,
sync_timer_r,
@@ -80,19 +78,19 @@ impl Agent {
self,
listener: tokio::net::UnixListener,
) -> anyhow::Result<()> {
- let err =
- crate::actions::subscribe_to_notifications(self.state.clone())
- .await;
- if let Err(e) = err {
- eprintln!("failed to subscribe to notifications: {e:#}")
- }
-
enum Event {
Request(std::io::Result<tokio::net::UnixStream>),
Timeout(()),
Sync(()),
}
+ let err =
+ crate::actions::subscribe_to_notifications(self.state.clone())
+ .await;
+ if let Err(e) = err {
+ eprintln!("failed to subscribe to notifications: {e:#}");
+ }
+
let c: tokio::sync::mpsc::UnboundedReceiver<
notifications::NotificationMessage,
> = {
@@ -160,17 +158,19 @@ impl Agent {
let result = crate::actions::sync(None).await;
if let Err(e) = result {
eprintln!("failed to sync: {e:#}");
- } else {
- if !state
- .write()
- .await
- .notifications_handler
- .is_connected()
- {
- let err = crate::actions::subscribe_to_notifications(state).await;
- if let Err(e) = err {
- eprintln!("failed to subscribe to notifications: {e:#}")
- }
+ } else if !state
+ .write()
+ .await
+ .notifications_handler
+ .is_connected()
+ {
+ let err =
+ crate::actions::subscribe_to_notifications(
+ state,
+ )
+ .await;
+ if let Err(e) = err {
+ eprintln!("failed to subscribe to notifications: {e:#}");
}
}
});