macro actix_derive

Derive macros for actix actors

15 releases

0.6.2 Sep 12, 2024
0.6.1 Sep 10, 2023
0.6.0 Mar 21, 2021
0.5.0 Oct 27, 2019
0.0.2 Nov 16, 2017
Download history 51776/week @ 2024-07-15 58070/week @ 2024-07-22 57448/week @ 2024-07-29 55958/week @ 2024-08-05 65924/week @ 2024-08-12 65793/week @ 2024-08-19 67607/week @ 2024-08-26 61837/week @ 2024-09-02 69400/week @ 2024-09-09 57190/week @ 2024-09-16 70337/week @ 2024-09-23 76880/week @ 2024-09-30 59099/week @ 2024-10-07 72269/week @ 2024-10-14 76686/week @ 2024-10-21 67088/week @ 2024-10-28

277,575 downloads per month
Used in 183 crates (10 directly)

MIT/Apache

12KB
191 lines

actix-derive

Derive macros for actix actors.

crates.io Documentation Minimum Supported Rust Version License Dependency Status

Usage

use actix_derive::{Message, MessageResponse};

#[derive(MessageResponse)]
struct Added(usize);

#[derive(Message)]
#[rtype(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(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() {}

License

This project is licensed under either of

at your option.

Dependencies

~250–700KB
~17K SLoC