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

Object Safety§

This trait is not object safe.

Implementors§