#macro-derive #actor #actix-actor

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

#19 in #actix-actor

Download history 50858/week @ 2024-12-17 20995/week @ 2024-12-24 32165/week @ 2024-12-31 70059/week @ 2025-01-07 67003/week @ 2025-01-14 57980/week @ 2025-01-21 65017/week @ 2025-01-28 80582/week @ 2025-02-04 70864/week @ 2025-02-11 73945/week @ 2025-02-18 73653/week @ 2025-02-25 76943/week @ 2025-03-04 84605/week @ 2025-03-11 69378/week @ 2025-03-18 70177/week @ 2025-03-25 58296/week @ 2025-04-01

295,850 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

~225–670KB
~16K SLoC