Crates.io | xan-actor |
lib.rs | xan-actor |
version | |
source | src |
created_at | 2023-09-30 13:44:55.282393 |
updated_at | 2024-12-31 09:35:47.953008 |
description | Akka actor |
homepage | |
repository | https://github.com/Xanthorrhizol/actor |
max_upload_size | |
id | 988643 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
This version has breaking changes from the previous version. The previous version is not compatible with this version.
$ cargo add xan-actor bincode log
$ cargo add serde --features=serde_derive
$ cargo add tokio --features="rt-multi-thread macros sync"
xan_actor::actor_system!(
struct Message {
pub message: String,
},
...
);
xan_actor::actor!(
Actor, // actor name
Message, // message type
struct ActorResource {
pub data: String,
},
fn handle_message(&self, message: Message) -> String {
message.message
},
fn pre_start(&mut self) {},
fn post_stop(&mut self) {},
fn pre_restart(&mut self) {},
fn post_restart(&mut self) {},
true
);
#[tokio::main]
async fn main() {
let (mut actor_system, register_tx) = ActorSystem::new();
let actor = Actor::new(
address!("test".to_string(), "actor".to_string(), "*".to_string()),
ActorResource {
data: "test".to_string(),
},
register_tx,
);
...
}
#[tokio::main]
async fn main() {
...
let (_handle, ready_rx) = actor.run();
ready_rx.await.unwrap();
...
}
#[tokio::main]
async fn main() {
...
let response_rxs = send_msg!(
&mut actor_system,
address!("test".to_string(), "actor".to_string(), "*".to_string()), // actor address
&"test".to_string() // message
);
for response in recv_res!(String /* return type */, response_rxs) {
println!("{}", response);
}
...
}