Crates.io | actix_derive |
lib.rs | actix_derive |
version | 0.6.2 |
source | src |
created_at | 2017-11-16 16:53:39.42324 |
updated_at | 2024-09-12 20:23:24.8015 |
description | Derive macros for `actix` actors |
homepage | |
repository | https://github.com/actix/actix |
max_upload_size | |
id | 39559 |
size | 27,393 |
Derive macros for
actix
actors.
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() {}
This project is licensed under either of
at your option.