From 6f925f99227253f9ea62fd64aa35ea52718aaa50 Mon Sep 17 00:00:00 2001 From: psykose Date: Mon, 18 Nov 2024 22:58:44 +0100 Subject: [PATCH] dead code --- src/broadcast.rs | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 src/broadcast.rs diff --git a/src/broadcast.rs b/src/broadcast.rs deleted file mode 100644 index 1490ecb..0000000 --- a/src/broadcast.rs +++ /dev/null @@ -1,34 +0,0 @@ -// nice wrapper to have a Default impl for a (Sender, InactiveReceiver) pair - -use async_broadcast::{broadcast, InactiveReceiver, Receiver, Sender, TrySendError}; - -pub struct Broadcast { - pub sender: Sender, - inactive_receiver: InactiveReceiver, -} - -impl Default for Broadcast { - fn default() -> Self { - let (sender, receiver) = broadcast(N); - Self { - sender, - inactive_receiver: receiver.deactivate(), - } - } -} - -impl Broadcast where T: Clone { - pub fn receiver(&self) -> Receiver { - self.inactive_receiver.activate_cloned() - } - - // like sender.try_broadcast, but ignores if there aren't any active listeners - pub fn try_broadcast(&self, msg: T) -> Result<(), TrySendError> { - match self.sender.try_broadcast(msg) { - Err(TrySendError::Inactive(_)) => Ok(()), // ignore - Err(err) => Err(err), - Ok(Some(_)) => unreachable!("we do not enable overflow mode"), - Ok(None) => Ok(()), - } - } -}