Trait RemotableActor

Source
pub trait RemotableActor: Actor
where Self::Params: RemoteMessage,
{ // Required method fn gspawn( proc: &Proc, name: &str, serialized_params: Data, ) -> Pin<Box<dyn Future<Output = Result<ActorId, Error>> + Send>>; // Provided method fn get_type_id() -> TypeId { ... } }
Expand description

An Actor that can be spawned remotely.

Blanket-implemented for actors that opt in to remote spawn by also implementing Referable and Binds<A>, with serializable params:

impl<A> RemotableActor for A
where
    A: Actor + Referable + Binds<A>,
    A::Params: RemoteMessage,
{}

Bounds explained:

  • Referable: marks the type as eligible for typed remote references (ActorRef<A>); required because remote spawn ultimately hands back an ActorId that higher-level APIs may re-type as ActorRef<A>.
  • Binds<A>: lets the runtime wire this actor’s message ports when it is spawned (the blanket impl calls handle.bind::<A>()).
  • A::Params: RemoteMessage: constructor params must be (de)serializable to cross a process boundary.

gspawn is a type-erased entry point used by the remote spawn/registry machinery. It takes serialized params and returns the new actor’s ActorId; application code shouldn’t call it directly.

Required Methods§

Source

fn gspawn( proc: &Proc, name: &str, serialized_params: Data, ) -> Pin<Box<dyn Future<Output = Result<ActorId, Error>> + Send>>

A type-erased entry point to spawn this actor. This is primarily used by hyperactor’s remote actor registration mechanism.

Provided Methods§

Source

fn get_type_id() -> TypeId

The type ID of this actor.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<A> RemotableActor for A
where A: Actor + Referable + Binds<A>, A::Params: RemoteMessage,