20 lines
508 B
Rust
20 lines
508 B
Rust
|
//
|
||
|
use kameo::{actor::ActorRef, Actor};
|
||
|
|
||
|
use crate::{spawn, spawn_in_thread};
|
||
|
|
||
|
/// Adds a spawn mathod to the actor.
|
||
|
pub trait BaseActor: Actor {
|
||
|
async fn spawn<Parent: Actor>(self, parent_actor_ref: ActorRef<Parent>) -> ActorRef<Self> {
|
||
|
spawn!(parent_actor_ref, self)
|
||
|
}
|
||
|
|
||
|
async fn spawn_in_thread<Parent: Actor>(
|
||
|
self,
|
||
|
parent_actor_ref: ActorRef<Parent>,
|
||
|
) -> ActorRef<Self> {
|
||
|
spawn_in_thread!(parent_actor_ref, self)
|
||
|
}
|
||
|
}
|
||
|
impl<T: Actor> BaseActor for T {}
|