[][src]Struct xaynet_server::state_machine::initializer::StateMachineInitializer

pub struct StateMachineInitializer<C, M> where
    C: CoordinatorStorage,
    M: ModelStorage
{ /* fields omitted */ }

The state machine initializer that initializes a new state machine.

Implementations

impl<C, M> StateMachineInitializer<C, M> where
    C: CoordinatorStorage,
    M: ModelStorage
[src]

pub fn new(
    pet_settings: PetSettings,
    mask_settings: MaskSettings,
    model_settings: ModelSettings,
    #[cfg(feature = "model-persistence")] restore_settings: RestoreSettings,
    store: Store<C, M>
) -> Self
[src]

Creates a new StateMachineInitializer.

impl<C, M> StateMachineInitializer<C, M> where
    C: CoordinatorStorage,
    M: ModelStorage
[src]

pub async fn init(
    self
) -> Result<(StateMachine<C, M>, RequestSender, EventSubscriber), StateMachineInitializationError>
[src]

This is supported on crate feature model-persistence only.

Initializes a new StateMachine by trying to restore the previous coordinator state along with the latest global model. After a successful initialization, the state machine always starts from a new round. This means that the round id is increased by one. If the state machine is reset during the initialization, the state machine starts with the round id 1.

Behavior

  • If the [RestoreSettings.enable] flag is set to false, the current coordinator state will be reset and a new StateMachine is created with the given settings.
  • If no coordinator state exists, the current coordinator state will be reset and a new StateMachine is created with the given settings.
  • If a coordinator state exists but no global model has been created so far, the StateMachine will be restored with the coordinator state but without a global model.
  • If a coordinator state and a global model exists, the StateMachine will be restored with the coordinator state and the global model.
  • If a global model has been created but does not exists, the initialization will fail with StateMachineInitializationError::GlobalModelUnavailable.
  • If a global model exists but its properties do not match the coordinator model settings, the initialization will fail with StateMachineInitializationError::GlobalModelInvalid.
  • Any network error will cause the initialization to fail.

Auto Trait Implementations

impl<C, M> RefUnwindSafe for StateMachineInitializer<C, M> where
    C: RefUnwindSafe,
    M: RefUnwindSafe
[src]

impl<C, M> Send for StateMachineInitializer<C, M>[src]

impl<C, M> Sync for StateMachineInitializer<C, M>[src]

impl<C, M> Unpin for StateMachineInitializer<C, M> where
    C: Unpin,
    M: Unpin
[src]

impl<C, M> UnwindSafe for StateMachineInitializer<C, M> where
    C: UnwindSafe,
    M: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<T> WithSubscriber for T[src]