pub trait State: Plugin {
type StateFeatures: FeatureCollection<'static>;
// Required methods
fn save(
&self,
store: StoreHandle<'_>,
features: Self::StateFeatures,
) -> Result<(), StateErr>;
fn restore(
&mut self,
store: RetrieveHandle<'_>,
features: Self::StateFeatures,
) -> Result<(), StateErr>;
}Expand description
A plugin extension that lets a plugins save and restore it’s state.
This extension contains two new methods: save and restore. These are called by the host to save and restore the state of the plugin, which is done with a handle.
You can also add a feature collection to retrieve host features; It works just like the plugin’s feature collection: You create a struct with multiple Features, derive FeatureCollection for it, and set the StateFeatures type to it. Then, the framework will try to populate it with the features supplied by the host and pass it to the method.
Required Associated Types§
Sourcetype StateFeatures: FeatureCollection<'static>
type StateFeatures: FeatureCollection<'static>
Required Methods§
Sourcefn save(
&self,
store: StoreHandle<'_>,
features: Self::StateFeatures,
) -> Result<(), StateErr>
fn save( &self, store: StoreHandle<'_>, features: Self::StateFeatures, ) -> Result<(), StateErr>
Save the state of the plugin.
The storage is done with the store handle. You draft a property, write it using the property handle, and then commit it to the store.
Sourcefn restore(
&mut self,
store: RetrieveHandle<'_>,
features: Self::StateFeatures,
) -> Result<(), StateErr>
fn restore( &mut self, store: RetrieveHandle<'_>, features: Self::StateFeatures, ) -> Result<(), StateErr>
Restore the state of the plugin.
The properties you have previously written can be retrieved with the store handle.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.