pub trait Producer: Serialize + Deserialize {
// Required method
fn produce(&mut self) -> Box<dyn Actor>;
// Provided method
fn from_string(&self, content: String) -> Result<Box<dyn Producer>> { ... }
}Expand description
§Producer
Implementation of an Actor trait involves two steps. First, implementation of the
Actor trait itself. Once trait implentation is done - first step is complete. Making
Actor instances available to system is job of the Producer. A Producer trait
implemenation(each Producer implementation with an unique typetag name) is
responsible for creating Actor instances at runtime. The Producer trait has the
produce method - which gets invoked to hand out Actor instances during actor
registration and restoration. So, the second step of Actor implemenation is to
implement the Producer trait. While registering an Actor to the system - the
define_actor! macro takes a serde serializable(https://github.com/serde-rs/serde)
Producer instance and a name for the actor(string - which could be anything - a
name for the actor). The Producer implemenation gets serialized and stored in the
backing store.