use crate::UErrorBt; use crossbeam::channel::{self, Receiver, Sender}; use once_cell::sync::OnceCell; type ChanError = UErrorBt; static ERR_CHAN: OnceCell = OnceCell::new(); pub struct ErrChan { tx: Sender, rx: Receiver, } impl ErrChan { fn get() -> &'static Self { ERR_CHAN.get_or_init(|| { let (tx, rx) = channel::bounded(20); Self { tx, rx } }) } pub fn send(msg: impl Into) { Self::get().tx.send(msg.into()).unwrap() } pub fn recv() -> ChanError { Self::get().rx.recv().unwrap() } }