Expand description
§acktor-ipc
Interprocess communication for the acktor actor
framework.
§About
acktor-ipc lets actors in different processes talk to each other over a transport of your
choice. It introduces a Node actor that owns one or more listeners and per-connection
Session actors that mediate traffic.
§Concepts
- Node — a long-lived actor that holds the listener(s) for inbound connections, tracks the
active sessions, and owns the registry of remote-addressable / remote-spawnable actor types.
Send
Connect<C>to it to dial out. - Session — a per-connection actor that wraps a single
IpcConnection, routes inbound frames to the right local actor, forwards outbound messages, and correlates request/response tags. - RemoteAddressable (re-exported from
acktor) — derive on an actor (with#[message(M1, M2, ...)]) to declare the message types it can receive from other processes. Messages must implementMessageId,Encode, andDecode; theirResults must implementEncode+Decode. - RemoteSpawnable (re-exported from
acktor) — implement to allow other processes to spawn this actor on this node. #[remote]— attribute applied to theimpl Actor for ...block of a remote-addressable actor; required so the actor exposes a remote mailbox.
§Example
A minimal message definition for IPC looks like:
ⓘ
use acktor::{Message, MessageId};
use acktor_ipc::{Decode, Encode};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
#[derive(
Debug, Clone, Copy,
KnownLayout, Immutable, FromBytes, IntoBytes,
Message, MessageId, Encode, Decode,
)]
#[codec(zerocopy)]
#[result_type(())]
#[repr(C)]
pub struct Ping {
pub id: u64,
pub timestamp: i64,
}See the pingpong example in the repository for a complete client/server walkthrough using
the WebSocket transport.
§Feature Flags
Defaults: derive.
| Feature | Purpose |
|---|---|
derive | Re-exports the #[remote] attribute macro. |
pipe | Pipe transport (Unix sockets / Windows pipes). |
websocket | WebSocket transport. |
Neither transport is enabled by default — enable pipe and/or websocket to pick the
transports you want.
Re-exports§
pub use error::NodeError;pub use error::SessionError;pub use ipc_method::IpcConnection;pub use ipc_method::IpcListener;pub use node::Node;pub use node::NodeEvent;pub use session::Session;
Modules§
- codec
- Codec traits for encoding and decoding remote messages.
- double_
map - A map-like container supporting lookup by two independent key types.
- error
- Error types used by this crate.
- ipc_
method - Traits for Inter-Process Communication (IPC) and some pre-implemented IPC methods.
- node
- Node actor for managing IPC connections and sessions.
- session
- Per-connection session actor.
Enums§
- Actor
Ref - An actor reference which can be used to identify an actor in a node by either its index or label.
- Decode
Error - Error type used by
Decode. - Encode
Error - Error type used by
Encode.
Traits§
- Decode
- Describes how to decode a message.
- Decode
Context - Context for decoding messages.
- Encode
- Describes how to encode a message.
- Encode
Context - Context for encoding messages.
- Remote
Addressable - An actor which can be reached from other processes.
- Remote
Spawnable - An actor type which can be created from another process.
- Stable
Id - A trait for types that have a stable unique iidentifier.
Attribute Macros§
- remote
derive - Attribute macro applies to the
impl Actor for MyActorblock, which overrides the internal methodActor::remote_mailboxto return aRemoteMailboxfor a remote addressable actor.
Derive Macros§
- Decode
- Derive the
Decodetrait for a message. - Encode
- Derive the
Encodetrait for a message. - Remote
Addressable - Derive the
RemoteAddressabletrait for an actor. - Stable
Id - Derive the
StableIdtrait for a type.