struct Example; impl ruw::Ruw for Example { type State = Vec; type Delta = Vec; type Error = async_std::io::Error; type TrackOne = (); type TrackMany = (); async fn read(&self) -> Result { async_std::fs::read("examples/temp.txt").await } fn update(state: Self::State, delta: Self::Delta) -> Result { let _ = state; Ok(delta) } async fn write(&self, old: Self::State, new: Self::State) -> Result<(), Self::Error> { let _ = old; async_std::task::sleep(std::time::Duration::from_secs(2)).await; async_std::fs::write("examples/temp.txt", new).await } fn accept((): Self::TrackMany) {} fn reject((): Self::TrackMany, error: Self::Error) { eprintln!("{error}"); } } #[async_std::main] async fn main() -> Result<(), async_std::io::Error> { let (sender, receiver) = async_std::channel::unbounded(); async_std::task::spawn(ruw::ruw(&Example, receiver)); let stdin = async_std::io::stdin(); loop { let mut line = String::new(); stdin.read_line(&mut line).await?; let _ = sender.send((line.into(), ())).await; } }