state_unit

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

Required Methods§

Source

async fn start(&mut self)

Start asynchronous processing.

Source

async fn stop(&mut self)

Stop asynchronous processing.

Source

async fn reset(&mut self) -> Result<()>

Reset to initial state.

Must only be called while stopped.

Source

async fn save(&mut self) -> Result<Option<SavedStateBlob>, SaveError>

Save state.

Must only be called while stopped.

Source

async fn restore(&mut self, buffer: SavedStateBlob) -> Result<(), RestoreError>

Restore state.

Must only be called while stopped.

Provided Methods§

Source

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.

Implementors§