pub(crate) fn start_canister(
        &self,
        canister_id: CanisterId,
        sender: PrincipalId,
        state: &mut ReplicatedState,
    ) -> Result<Vec<StopCanisterContext>, CanisterManagerError> {
        let canister = state
            .canister_state(&canister_id)
            .ok_or_else(|| CanisterManagerError::CanisterNotFound(canister_id))?;

        self.validate_controller(&canister, &sender)?;

        let mut canister = state.take_canister_state(&canister_id).unwrap();

        let stop_contexts = match &mut canister.system_state.status {
            CanisterStatus::Stopping { stop_contexts, .. } => mem::replace(stop_contexts, vec![]),
            CanisterStatus::Running { .. } | CanisterStatus::Stopped => {
                Vec::new() // No stop contexts to return.
            }
        };

        // Transition the canister into "running".
        canister.system_state.status = match canister.system_state.status {
            CanisterStatus::Running {
                call_context_manager,
            }
            | CanisterStatus::Stopping {
                call_context_manager,
                ..
            } => CanisterStatus::Running {
                call_context_manager,
            },
            CanisterStatus::Stopped => CanisterStatus::new_running(),
        };

        state.put_canister_state(canister);
        Ok(stop_contexts)
    }
/// Signals a canister to start.
///
/// If the canister is stopped, then the canister is immediately
/// transitioned into the "running" state.
///
/// If the canister is already running, this operation is a no-op.
///
/// If the canister is in the process of being stopped (i.e stopping), then
/// the canister is transitioned back into a running state and the
/// `stop_contexts` that were used for stopping the canister are
/// returned.
Signals a canister to start.
If the canister is stopped, then the canister is immediately
transitioned into the "running" state.

If the canister is already running, this operation is a no-op.

If the canister is in the process of being stopped , then
the canister is transitioned back into a running state and the
`stop_contexts` that were used for stopping the canister are
returned.
Signals a canister to start . If the canister is stopped then the canister is immediately transitioned into the " running " state . If the canister is already running this operation is a no - op . If the canister is in the process of being stopped then the canister is transitioned back into a running state and the ` stop_contexts ` that were used for stopping the canister are returned .
pub(crate) fn start_canister(
        &self,
        canister_id: CanisterId,
        sender: PrincipalId,
        state: &mut ReplicatedState,
    ) -> Result<Vec<StopCanisterContext>, CanisterManagerError> {
        let canister = state
            .canister_state(&canister_id)
            .ok_or_else(|| CanisterManagerError::CanisterNotFound(canister_id))?;
        self.validate_controller(&canister, &sender)?;
        let mut canister = state.take_canister_state(&canister_id).unwrap();
        let stop_contexts = match &mut canister.system_state.status {
            CanisterStatus::Stopping { stop_contexts, .. } => mem::replace(stop_contexts, vec![]),
            CanisterStatus::Running { .. } | CanisterStatus::Stopped => {
                Vec::new() // No stop contexts to return.
            }
        };
        // Transition the canister into "running".
        canister.system_state.status = match canister.system_state.status {
            CanisterStatus::Running {
                call_context_manager,
            }
            | CanisterStatus::Stopping {
                call_context_manager,
                ..
            } => CanisterStatus::Running {
                call_context_manager,
            },
            CanisterStatus::Stopped => CanisterStatus::new_running(),
        };
        state.put_canister_state(canister);
        Ok(stop_contexts)
    }
pub ( crate ) fn start_canister ( & self , canister_id : CanisterId , sender : PrincipalId , state : & mut ReplicatedState , ) -> Result < Vec < StopCanisterContext > , CanisterManagerError > { let canister = state . canister_state ( & canister_id ) . ok_or_else ( | | CanisterManagerError :: CanisterNotFound ( canister_id ) ) ? ; self . validate_controller ( & canister , & sender ) ? ; let mut canister = state . take_canister_state ( & canister_id ) . unwrap ( ) ; let stop_contexts = match & mut canister . system_state . status { CanisterStatus :: Stopping { stop_contexts , .. } => mem :: replace ( stop_contexts , vec ! [ ] ) , CanisterStatus :: Running { .. } | CanisterStatus :: Stopped => { Vec :: new ( ) // No stop contexts to return. } } ; // Transition the canister into "running". canister . system_state . status = match canister . system_state . status { CanisterStatus :: Running { call_context_manager , } | CanisterStatus :: Stopping { call_context_manager , .. } => CanisterStatus :: Running { call_context_manager , } , CanisterStatus :: Stopped => CanisterStatus :: new_running ( ) , } ; state . put_canister_state ( canister ) ; Ok ( stop_contexts ) }
Signals a canister to start.
Signals a canister to start .
&self
canister_id
CanisterId
sender
PrincipalId
state
&mut ReplicatedState
&self
canister_id
CanisterId
sender
PrincipalId
state
&mut ReplicatedState