use actix::{Actor, Handler, System}; use actix_derive::{Message, MessageResponse}; use actix_handler_macro::Actor; #[derive(MessageResponse)] struct Added(usize); #[derive(Message)] #[rtype(result = "Added")] struct Sum(usize, usize); #[derive(Actor, Default)] #[actor(context = "::actix::SyncContext")] struct Adder; impl Handler for Adder { type Result = ::Result; fn handle(&mut self, msg: Sum, _: &mut Self::Context) -> Added { Added(msg.0 + msg.1) } } #[test] fn test_message() { let mut sys = System::new("actix-test-runtime"); let addr = Adder::start_default(); let res = sys.block_on(addr.send(Sum(3, 5))).unwrap(); assert_eq!(res.0, 8); }