Earst is a Rust library to enable IPC on Unix-like platforms through FIFO special files.
use std::io::stdin;
use earst::Sender;
#[tokio::main]
fn main() -> Result<(), std::io::Error> {
let mut sender = Sender::open("~/my-pipe").await?;
let input = stdin();
loop {
let mut message = String::new();
input.read_line(&mut message)?;
sender.send(&message.as_bytes()[..}).await?;
}
}
use earst::Receiver;
#[tokio::main]
fn main() {
let mut receiver = Receiver::open("~/my-pipe").await.unwrap();
loop {
let message = receiver.receive().await.unwrap();
let message = String::from_utf8(message).unwrap();
println!("{}", message);
}
}