Actix is a rust actor framework.
- API Documentation (Development)
- API Documentation (Releases)
- Cargo package: actix
actix-derive
adds support for Rust Custom Derive / Macros 1.1 toactix
use actix_derive::{Message, MessageResponse};
#[derive(MessageResponse)]
struct Added(usize);
#[derive(Message)]
#[rtype(result = "Added")]
struct Sum(usize, usize);
fn main() {}
This code expands into following code:
use actix::{Actor, Context, Handler, System};
use actix_derive::{Message, MessageResponse};
#[derive(MessageResponse)]
struct Added(usize);
#[derive(Message)]
#[rtype(result = "Added")]
struct Sum(usize, usize);
#[derive(Default)]
struct Adder;
impl Actor for Adder {
type Context = Context<Self>;
}
impl Handler<Sum> for Adder {
type Result = <Sum as actix::Message>::Result;
fn handle(&mut self, msg: Sum, _: &mut Self::Context) -> Added {
Added(msg.0 + msg.1)
}
}
fn main() {}
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.