diff --git a/src/actor/actor_ref.rs b/src/actor/actor_ref.rs index 7cf22c6..f87edce 100644 --- a/src/actor/actor_ref.rs +++ b/src/actor/actor_ref.rs @@ -863,6 +863,26 @@ impl fmt::Debug for RemoteActorRef { } } +#[cfg(feature = "remote")] +impl From> for RemoteActorRef { + fn from(actor_ref: ActorRef) -> Self { + let swarm_tx = remote::ActorSwarm::get() + .expect("swarm not bootstrapped") + .sender(); + RemoteActorRef::new(actor_ref.id, swarm_tx) + } +} + +#[cfg(feature = "remote")] +impl From<&ActorRef> for RemoteActorRef { + fn from(actor_ref: &ActorRef) -> Self { + let swarm_tx = remote::ActorSwarm::get() + .expect("swarm not bootstrapped") + .sender(); + RemoteActorRef::new(actor_ref.id, swarm_tx) + } +} + /// A actor ref that does not prevent the actor from being stopped. /// /// If all [`ActorRef`] instances of an actor were dropped and only diff --git a/src/remote/swarm.rs b/src/remote/swarm.rs index 28a4daa..b40cc7d 100644 --- a/src/remote/swarm.rs +++ b/src/remote/swarm.rs @@ -342,6 +342,10 @@ impl ActorSwarm { } } } + + pub(crate) fn sender(&self) -> SwarmSender { + self.swarm_tx.clone() + } } struct SwarmActor {