actori_derive

Crates.ioactori_derive
lib.rsactori_derive
version0.5.0
sourcesrc
created_at2020-01-20 00:21:55.308051
updated_at2020-01-20 00:21:55.308051
descriptionActor framework for Rust
homepagehttps://github.com/actori/actori-derive/
repositoryhttps://github.com/actori/actori-derive.git
max_upload_size
id200304
size22,243
Christian Haynes (06chaynes)

documentation

https://docs.rs/actori-derive/

README

actix-derive Build Status crates.io

Actix is a rust actor framework.


Actix is licensed under the Apache-2.0 license.

Features

  • actix-derive adds support for Rust Custom Derive / Macros 1.1 to actix

Usage

#[macro_use] extern crate actix_derive;

use std::io::Error;

#[derive(Message)]
#[rtype(result="Result<usize, Error>")]
struct Sum(usize, usize);

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

fn main() {}

This code expands into following code:

extern crate actix;
use std::io::Error;
use actix::dev::MessageResponse;
use actix::dev::ResponseChannel;
use actix::Message;

struct Sum(usize, Error);

impl Message for Sum {
    type Result = Result<usize, Error>;
}

struct Added(usize);

impl<A, M> MessageResponse<A, M> for Added
where
  A: Actor,
  M: Message<Result = Added>
{
    fn handle<R: ResponseChannel<M>>(self, _: &mut A::Context, tx: Option<R>) {
        if let Some(tx) = tx {
            tx.send(self);
        }
    }
}

fn main() {}

License

This project is licensed under either of

at your option.

Commit count: 0

cargo fmt