pub trait Producer: Serialize + Deserialize {
    fn produce(&mut self) -> Box<dyn Actor>;

    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.

Required methods

The method to be implemented to create Actor instances. The implementing type should be tagged with a non-colliding typetag name in the format #[typetag::serde(name = “an_actor_producer”)]

https://github.com/dtolnay/typetag

Provided methods

A method to rebuild a Producer implementation. Used internally by the system to generate Producers on demand from the backing store.

Trait Implementations

Serialize this value into the given Serde serializer. Read more

Serialize this value into the given Serde serializer. Read more

Serialize this value into the given Serde serializer. Read more

Serialize this value into the given Serde serializer. Read more

Implementors