Trait state_unit::StateUnit
source · pub trait StateUnit: InspectMut {
// Required methods
async fn start(&mut self);
async fn stop(&mut self);
async fn reset(&mut self) -> Result<()>;
async fn save(&mut self) -> Result<Option<SavedStateBlob>, SaveError>;
async fn restore(
&mut self,
buffer: SavedStateBlob,
) -> Result<(), RestoreError>;
// Provided method
async fn post_restore(&mut self) -> Result<()> { ... }
}
Expand description
Trait implemented by an object that can act as a state unit.
Implementing this is optional, to be used with UnitBuilder::spawn
or
StateRequest::apply
; state units can also directly process incoming
StateRequest
s.
Required Methods§
sourceasync fn reset(&mut self) -> Result<()>
async fn reset(&mut self) -> Result<()>
Reset to initial state.
Must only be called while stopped.
Provided Methods§
sourceasync fn post_restore(&mut self) -> Result<()>
async fn post_restore(&mut self) -> Result<()>
Complete the restore process, after all dependencies have been restored.
Must only be called while stopped.
Object Safety§
This trait is not object safe.