You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
999 B
43 lines
999 B
3 years ago
|
use xtra::spawn::TokioGlobalSpawnExt;
|
||
|
use xtra::Actor;
|
||
|
use xtra_productivity::xtra_productivity;
|
||
|
|
||
|
struct DummyActor;
|
||
|
|
||
|
impl xtra::Actor for DummyActor {}
|
||
|
|
||
|
#[derive(Clone)]
|
||
|
struct DummyMessage;
|
||
|
|
||
|
struct DummyMessageWithContext;
|
||
|
|
||
|
// Dummy actor, xtra::Handler and xtra::Message impls generated by xtra_productivity
|
||
|
#[xtra_productivity]
|
||
|
impl DummyActor {
|
||
|
pub fn handle_dummy_message(&mut self, message: DummyMessage) -> i32 {
|
||
|
let _ = message.clone();
|
||
|
0
|
||
|
}
|
||
|
|
||
|
pub fn handle_dummy_message_with_context(
|
||
|
&mut self,
|
||
|
_message: DummyMessageWithContext,
|
||
|
context: &mut xtra::Context<Self>,
|
||
|
) {
|
||
|
let _ = context.address();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
fn is_i32(_: i32) {}
|
||
|
|
||
|
#[tokio::main]
|
||
|
async fn main() {
|
||
|
// Create dummy actor
|
||
|
let dummy_actor = DummyActor.create(None).spawn_global();
|
||
|
|
||
|
// Send message to dummy actor
|
||
|
let i32 = dummy_actor.send(DummyMessage).await.unwrap();
|
||
|
is_i32(i32);
|
||
|
dummy_actor.send(DummyMessageWithContext).await.unwrap();
|
||
|
}
|