git-next/crates/cli/src/base_actor.rs

20 lines
508 B
Rust
Raw Normal View History

//
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 {}