🚧 Add an interface to the ChatsWindows to drive its behavior
For now, only the ChatsWindow tabs are toggled on clicks on room names (from ContactsSection).
This commit is contained in:
28
src/utils.rs
Normal file
28
src/utils.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
use tokio::sync::mpsc::{channel, Receiver as _Receiver, Sender as _Sender};
|
||||
|
||||
pub struct Receiver<T>(_Receiver<T>);
|
||||
|
||||
impl<T> Receiver<T> {
|
||||
pub(super) async fn recv(&mut self) -> Option<T> {
|
||||
self.0.recv().await
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Sender<T>(_Sender<T>);
|
||||
|
||||
// TODO: Handle error
|
||||
impl<T> Sender<T> {
|
||||
pub(super) async fn send(self, t: T) {
|
||||
// self.0.send(t).unwrap();
|
||||
let _ = self.0.send(t).await;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Rename the name of the following fn
|
||||
pub fn oneshot<T>() -> (Sender<T>, Receiver<T>) {
|
||||
let (tx, rx) = channel(32);
|
||||
let sender = Sender(tx);
|
||||
let receiver = Receiver(rx);
|
||||
|
||||
(sender, receiver)
|
||||
}
|
Reference in New Issue
Block a user