diff options
author | Jesse Luehrs <doy@tozt.net> | 2023-07-16 16:28:48 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2023-07-16 16:29:07 -0400 |
commit | eb4669dbb7b9eb9175720ea12f2fa47f95158070 (patch) | |
tree | a8b49eec3ff7ec705a2959d3e970da42e02052cc /src/bin/rbw-agent/notifications.rs | |
parent | 3e9bcc72938feee1491124ff8c5e8bec2f15bedc (diff) | |
download | rbw-eb4669dbb7b9eb9175720ea12f2fa47f95158070.tar.gz rbw-eb4669dbb7b9eb9175720ea12f2fa47f95158070.zip |
clippy and fmt
Diffstat (limited to 'src/bin/rbw-agent/notifications.rs')
-rw-r--r-- | src/bin/rbw-agent/notifications.rs | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/bin/rbw-agent/notifications.rs b/src/bin/rbw-agent/notifications.rs index e8f84b0..69ebda5 100644 --- a/src/bin/rbw-agent/notifications.rs +++ b/src/bin/rbw-agent/notifications.rs @@ -38,7 +38,7 @@ fn parse_messagepack(data: &[u8]) -> Option<NotificationMessage> { let message_type = unpacked_message.iter().next().unwrap().as_u64().unwrap(); - let message = match message_type { + match message_type { 0 => Some(NotificationMessage::SyncCipherUpdate), 1 => Some(NotificationMessage::SyncCipherCreate), 2 => Some(NotificationMessage::SyncLoginDelete), @@ -52,12 +52,10 @@ fn parse_messagepack(data: &[u8]) -> Option<NotificationMessage> { 10 => Some(NotificationMessage::SyncSettings), 11 => Some(NotificationMessage::Logout), _ => None, - }; - - return message; + } } -pub struct NotificationsHandler { +pub struct Handler { write: Option< futures::stream::SplitSink< tokio_tungstenite::WebSocketStream< @@ -74,7 +72,7 @@ pub struct NotificationsHandler { >, } -impl NotificationsHandler { +impl Handler { pub fn new() -> Self { Self { write: None, @@ -99,7 +97,7 @@ impl NotificationsHandler { self.write = Some(write); self.read_handle = Some(read_handle); - return Ok(()); + Ok(()) } pub fn is_connected(&self) -> bool { @@ -128,7 +126,7 @@ impl NotificationsHandler { let (tx, rx) = tokio::sync::mpsc::unbounded_channel::<NotificationMessage>(); self.sending_channels.write().await.push(tx); - return rx; + rx } } @@ -167,7 +165,8 @@ async fn subscribe_to_notifications( Ok(Message::Binary(binary)) => { let msgpack = parse_messagepack(&binary); if let Some(msg) = msgpack { - for channel in a.iter() { + let channels = a.as_slice(); + for channel in channels { let res = channel.send(msg); if res.is_err() { eprintln!("error sending websocket message to channel"); @@ -176,12 +175,12 @@ async fn subscribe_to_notifications( } }, Err(e) => { - eprintln!("websocket error: {:?}", e); + eprintln!("websocket error: {e:?}"); }, _ => {} } }).await; }; - return Ok((write, tokio::spawn(read_future))); + Ok((write, tokio::spawn(read_future))) } |