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 |
298,048 downloads per month
Used in 182 crates
(10 directly)
12KB
191 lines
actix-derive
Derive macros for
actix
actors.
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
- 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.
Dependencies
~235–680KB
~16K SLoC