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 56953/week @ 2024-07-30 58450/week @ 2024-08-06 63632/week @ 2024-08-13 66744/week @ 2024-08-20 64030/week @ 2024-08-27 65890/week @ 2024-09-03 67039/week @ 2024-09-10 58001/week @ 2024-09-17 71697/week @ 2024-09-24 75625/week @ 2024-10-01 59123/week @ 2024-10-08 74181/week @ 2024-10-15 76295/week @ 2024-10-22 65318/week @ 2024-10-29 51813/week @ 2024-11-05 69566/week @ 2024-11-12

275,080 downloads per month
Used in 182 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

~205–630KB
~15K SLoC