RemoteSpawn

Trait RemoteSpawn 

Source
pub trait RemoteSpawn:
    Actor
    + Referable
    + Binds<Self> {
    type Params: RemoteMessage;

    // Required method
    fn new<'async_trait>(
        params: Self::Params,
        environment: Flattrs,
    ) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
       where Self: 'async_trait;

    // Provided methods
    fn gspawn(
        proc: &Proc,
        name: &str,
        serialized_params: Data,
        environment: Flattrs,
    ) -> Pin<Box<dyn Future<Output = Result<ActorId, Error>> + Send>> { ... }
    fn get_type_id() -> TypeId { ... }
}
Expand description

An Actor that can be spawned remotely.

Bounds explained:

  • Actor: only actors may be remotely spawned.
  • 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<Self>: lets the runtime wire this actor’s message ports when it is spawned (the blanket impl calls handle.bind::<Self>()).

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 Associated Types§

Source

type Params: RemoteMessage

The type of parameters used to instantiate the actor remotely.

Required Methods§

Source

fn new<'async_trait>( params: Self::Params, environment: Flattrs, ) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
where Self: 'async_trait,

Creates a new actor instance given its instantiation parameters. The environment allows whoever is responsible for spawning this actor to pass in additional context that may be useful.

Provided Methods§

Source

fn gspawn( proc: &Proc, name: &str, serialized_params: Data, environment: Flattrs, ) -> 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.

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 RemoteSpawn for PingPongActor

Source§

impl<A: Actor + Referable + Binds<Self> + Default> RemoteSpawn for A

If an actor implements Default, we use this as the RemoteSpawn implementation, too.