#macro-derive #actix-actor #actix #derive #actors #macro

actix_derive

actix 演员 deriving 宏

14 个版本

0.6.1 2023 年 9 月 10 日
0.6.0 2021 年 3 月 21 日
0.6.0-beta.12021 年 2 月 6 日
0.5.0 2019 年 10 月 27 日
0.0.2 2017 年 11 月 16 日

#1680 in 异步

Download history 61912/week @ 2024-03-14 48154/week @ 2024-03-21 67563/week @ 2024-03-28 48405/week @ 2024-04-04 54344/week @ 2024-04-11 51495/week @ 2024-04-18 53146/week @ 2024-04-25 48595/week @ 2024-05-02 51427/week @ 2024-05-09 59462/week @ 2024-05-16 52905/week @ 2024-05-23 61956/week @ 2024-05-30 66479/week @ 2024-06-06 56851/week @ 2024-06-13 56482/week @ 2024-06-20 45589/week @ 2024-06-27

239,257 每月下载量
用于 185 个 Crates (10 直接)

MIT/Apache

11KB
186

actix-derive

actix 演员 deriving 宏。

crates.io Documentation Minimum Supported Rust Version License Dependency Status

使用方法

use actix_derive::{Message, MessageResponse};

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

#[derive(Message)]
#[rtype(result = "Added")]
struct Sum(usize, usize);

fn main() {}

此代码扩展为以下代码

use actix::{Actor, Context, Handler, System};
use actix_derive::{Message, MessageResponse};

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

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

许可

此项目受以下任一许可的约束

由您选择。

依赖关系

~265–710KB
~17K SLoC