use std::sync::mpsc as std_mpsc; use tokio::sync::mpsc as tokio_mpsc; use tokio::task; pub fn proxy_channel(std_rx: std_mpsc::Receiver) -> tokio_mpsc::Receiver where T: 'static + Send + Sync, { let (tx, tokio_rx) = tokio_mpsc::channel(255); task::spawn_blocking(move || loop { let msg = match std_rx.recv() { Ok(msg) => msg, Err(_) => return, }; match tx.blocking_send(msg) { Ok(_) => {} Err(_) => return, } }); tokio_rx }