acktor-ipc 1.0.4

Interprocess communication support for the acktor actor framework
Documentation
//! Traits for actors which can be reached over IPC and a registry of this kind of actors.
//!

use std::sync::Arc;

use acktor::{Actor, Handler, HasStableTypeId};
use ahash::HashMap;

use crate::remote_message::RemoteMessage;

mod registry;
pub use registry::RemoteActorRegistry;

mod factory;
pub use factory::RemoteActorFactory;
pub(crate) use factory::{DynRemoteActorFactory, RemoteActorShim};

pub(crate) type RemoteActorFactoryRegistry = HashMap<String, Arc<dyn DynRemoteActorFactory>>;

/// A marker trait for actors which can be reached over IPC.
///
/// To make an actor reachable over IPC, the user should implement the [`Handler<RemoteMessage>`]
/// trait for an actor to define how it processes inbound remote messages, and then register the
/// actor's address in the [`Node`][crate::Node]'s [`RemoteActorRegistry`] via the
/// [`with_actor`][crate::Node::with_actor] method or the
/// [`AddActor`][crate::node::command::AddActor] command.
///
/// It is highly recommended to use the [`#[remote_actor]`][macro@crate::remote_actor] attribute
/// macro to annotate the `impl Actor for MyActor { ... }` block of a remote actor. The macro
/// overrides the [`Actor::type_erased_recipient_fn`] hook, which will opt-in the
/// `type-erased-recipient-hook` feature of the [`acktor`] crate, and enable the conversion from
/// any `Recipient` type backed by the actor's [`Address`][acktor::Address] to a
/// `Recipient<RemoteMessage>`. With the help of this hook, the actor's address will be registered
/// in the [`Node`][crate::Node]'s [`RemoteActorRegistry`] automatically when it is encoded for
/// the first time. This is more convenient than manual registration.
pub trait RemoteActor: Actor + Handler<RemoteMessage> + HasStableTypeId {}