Trait mechtron::Mechtron

source ·
pub trait Mechtron<P>: MechtronLifecycle<P> + Sync + Send + 'staticwhere
    P: Platform,
{ type Skel; type Cache; type State; fn restore(skel: Self::Skel, cache: Self::Cache, state: Self::State) -> Self; fn cache(_skel: Self::Skel) -> Result<Option<Self::Cache>, P::Err> { ... } }
Expand description

Create a Mechtron by implementing this trait. Mechtrons are created per request and disposed of afterwards… Implementers of this trait should only hold references to Mechtron::Skel, Mechtron::Cache & Mechtron::State at most.

Required Associated Types

it is recommended to implement MechtronSkel or some derivative of MechtronSkel. Skel holds info about the Mechtron (like it’s Point, exact Kind & Properties) The Skel may also provide access to other services within the Guest. If your Mechtron doesn’t use the Skel then implement type Skel=()

Is any static data (templates, config files) that does not change and may need to be reused. If your Mechtron doesn’t need a Cache then implement ```type Cache=()``

State is the aspect of the Mechtron that is changeable. It is recommended to wrap State in a Mutex or RwLock if used. If you are implementing a stateless mechtron then implement type State=();

Required Methods

This method is called by a companion MechtronFactory implementation to bring this Mechtron back to life to handle an Init or a Directed Wave

Provided Methods

create the Cache for this Mechtron (templates, configs & static content) the cache should hold any static content that is expected to be unchanging

Implementors