|
|
|
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) {}
|
|
|
|
|
|
|
|
struct DummyMessageWithoutMessageImpl;
|
|
|
|
|
|
|
|
#[xtra_productivity(message_impl = false)]
|
|
|
|
impl DummyActor {
|
|
|
|
pub fn handle_dummy_message_without_message_impl(
|
|
|
|
&mut self,
|
|
|
|
_message: DummyMessageWithoutMessageImpl,
|
|
|
|
) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl xtra::Message for DummyMessageWithoutMessageImpl {
|
|
|
|
type Result = ();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[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();
|
|
|
|
|
|
|
|
dummy_actor
|
|
|
|
.send(DummyMessageWithoutMessageImpl)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
}
|