Add cli & lib crates

This commit is contained in:
2021-04-22 15:13:28 +02:00
parent e39cffa3f6
commit 3a9ecc398a
53 changed files with 5065 additions and 99 deletions

24
cli/src/util.rs Normal file
View File

@ -0,0 +1,24 @@
use std::sync::mpsc as std_mpsc;
use tokio::sync::mpsc as tokio_mpsc;
use tokio::task;
pub fn proxy_channel<T>(std_rx: std_mpsc::Receiver<T>) -> tokio_mpsc::Receiver<T>
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
}