read_write_repeat/
read_write_repeat.rs1use async_std::{io, task};
2use unix_fifo_async::NamedPipePath;
3
4fn main() -> io::Result<()> {
13 task::block_on(async move {
14 let pipe = NamedPipePath::new("./reverse_me");
15 let writer = pipe.open_write();
16 let reader = pipe.open_read();
17 loop {
18 pipe.ensure_exists().unwrap();
19 println!("Waiting for message...");
20 let msg = reader.read_string().await?;
21
22 let answer = msg.chars().rev().collect::<String>() + "\n";
23 pipe.ensure_exists().unwrap();
24 println!("Received message, waiting for receiver...");
25 writer.write_str(&answer).await?;
26 }
27 })
28}