diff --git a/coerce/src/actor/message/mod.rs b/coerce/src/actor/message/mod.rs index b2956a37..d2da0cf8 100644 --- a/coerce/src/actor/message/mod.rs +++ b/coerce/src/actor/message/mod.rs @@ -9,9 +9,18 @@ //! //! ### Example //! ```rust,no_run -//! use coerce::actor::message::Handler; +//! use coerce::actor::Actor; +//! use coerce::actor::message::{Message, Handler}; //! use coerce::actor::context::ActorContext; //! +//! struct MyActor; +//! +//! impl Actor for MyActor { } +//! +//! struct MyMessage; +//! +//! impl Message for MyMessage { type Result = (); } +//! //! #[async_trait] //! impl Handler for MyActor { //! async fn handle(&mut self, message: MyMessage, ctx: &mut ActorContext) { diff --git a/coerce/src/actor/mod.rs b/coerce/src/actor/mod.rs index 303f0263..0d839c29 100644 --- a/coerce/src/actor/mod.rs +++ b/coerce/src/actor/mod.rs @@ -54,7 +54,11 @@ //! use async_trait::async_trait; //! use tokio::sync::oneshot::{channel, Sender}; //! -//! struct ParentActor { child_count: usize, completed_actors: usize, on_work_completed: Option>, } +//! struct ParentActor { +//! child_count: usize, +//! completed_actors: usize, +//! on_work_completed: Option>, +//! } //! //! struct ChildActor; //! diff --git a/coerce/src/remote/mod.rs b/coerce/src/remote/mod.rs index 450eecfc..81e2dcb3 100644 --- a/coerce/src/remote/mod.rs +++ b/coerce/src/remote/mod.rs @@ -2,8 +2,9 @@ //! //! Coerce clusters are identified by a [`NodeId`] and a string-based node tag. //! -//! The easiest way to create a full, batteries-included clustered actor system, is by using the [`RemoteActorSystemBuilder`]. -//! From here, you can configure and create a [`RemoteActorSystem`]. +//! The easiest way to create a full, batteries-included clustered actor system, is by +//! using the [`RemoteActorSystemBuilder`]. From here, you can customise and +//! create a [`RemoteActorSystem`]. //! //! ## Remote-enabled messages //! Messages are not available to be handled remotely by default, and do require being registered @@ -33,7 +34,12 @@ //! of a message of type `MyMessageType` registered, with the actor that processes the //! message as type `MyActorType`. //! -//! ```rust,no_run +//! Note that a prerequisite for messages to be able to be transmitted remotely is that as part +//! of defining the message, it must define how to serialise and deserialise to and from a `Vec`. +//! +//! ```rust +//! use coerce::actor::Actor; +//! use coerce::actor::message::{Message, MessageUnwrapErr, MessageWrapErr}; //! use coerce::remote::system::RemoteActorSystem; //! //! let remote_system = RemoteActorSystem::builder() @@ -44,6 +50,24 @@ //! handlers //! .with_handler::("MyActorType.MyMessageType") //! }); +//! +//! struct MyActor; +//! +//! impl Actor for MyActor { } +//! +//! struct MyMessage; +//! +//! impl Message for MyMessage { +//! type Result = (); +//! +//! fn as_bytes(&self) -> Result, MessageWrapErr> { +//! Ok(vec![]) +//! } +//! +//! fn from_bytes(_: Vec) -> Result { +//! Ok(Self) +//! } +//! } //! ``` //! //! [`NodeId`]: system::NodeId