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.
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.