use acty::{Actor, ActorExt, AsyncClose};
use futures::{Stream, StreamExt};
use std::pin::pin;
struct Echo;
impl Actor for Echo {
type Message = String;
async fn run(self, inbox: impl Stream<Item = Self::Message> + Send) {
let mut inbox = pin!(inbox);
while let Some(msg) = inbox.next().await {
println!("echo: {}", msg);
}
}
}
#[tokio::main]
async fn main() {
let echo = Echo.start();
echo.send("Hello".to_string()).unwrap_or(());
echo.send("World".to_string()).unwrap_or(());
echo.send("!".to_string()).unwrap_or(());
echo.close().await;
}