pub fn take_execution_result(
        &mut self,
        wasm_run_error: Option<&HypervisorError>,
    ) -> HypervisorResult<Option<WasmResult>> {
        match &mut self.api_type {
            ApiType::Start { .. }
            | ApiType::Init { .. }
            | ApiType::Heartbeat { .. }
            | ApiType::Cleanup { .. }
            | ApiType::ReplicatedQuery { .. }
            | ApiType::PreUpgrade { .. }
            | ApiType::InspectMessage { .. }
            | ApiType::NonReplicatedQuery { .. } => (),
            ApiType::Update {
                outgoing_request, ..
            }
            | ApiType::ReplyCallback {
                outgoing_request, ..
            }
            | ApiType::RejectCallback {
                outgoing_request, ..
            } => {
                if let Some(outgoing_request) = outgoing_request.take() {
                    self.system_state_accessor
                        .canister_cycles_refund(outgoing_request.take_cycles());
                }
            }
        }
        if let Some(err) = wasm_run_error
            .cloned()
            .or_else(|| self.execution_error.take())
        {
            // Return allocated memory in case of failed message execution.
            self.memory_usage
                .deallocate_memory(self.memory_usage.allocated_memory);
            return Err(err);
        }
        match &mut self.api_type {
            ApiType::Start { .. }
            | ApiType::Init { .. }
            | ApiType::PreUpgrade { .. }
            | ApiType::Cleanup { .. }
            | ApiType::Heartbeat { .. } => Ok(None),
            ApiType::InspectMessage {
                message_accepted, ..
            } => {
                if *message_accepted {
                    Ok(None)
                } else {
                    Err(HypervisorError::MessageRejected)
                }
            }
            ApiType::Update {
                response_status, ..
            }
            | ApiType::ReplicatedQuery {
                response_status, ..
            }
            | ApiType::NonReplicatedQuery {
                response_status, ..
            }
            | ApiType::ReplyCallback {
                response_status, ..
            }
            | ApiType::RejectCallback {
                response_status, ..
            } => match response_status {
                ResponseStatus::JustRepliedWith(ref mut result) => Ok(result.take()),
                _ => Ok(None),
            },
        }
    }
/// Gets the result of execution, assuming there is no error from
/// running the canister. Returns any cycles used for an outgoing request
/// that doesn't get sent and returns allocated memory to the subnet if the
/// there is an error from running the canister.
Gets the result of execution, assuming there is no error from
running the canister. Returns any cycles used for an outgoing request
that doesn't get sent and returns allocated memory to the subnet if the
there is an error from running the canister.
Gets the result of execution assuming there is no error from running the canister . Returns any cycles used for an outgoing request that doesn ' t get sent and returns allocated memory to the subnet if the there is an error from running the canister .
pub fn take_execution_result(
        &mut self,
        wasm_run_error: Option<&HypervisorError>,
    ) -> HypervisorResult<Option<WasmResult>> {
        match &mut self.api_type {
            ApiType::Start { .. }
            | ApiType::Init { .. }
            | ApiType::Heartbeat { .. }
            | ApiType::Cleanup { .. }
            | ApiType::ReplicatedQuery { .. }
            | ApiType::PreUpgrade { .. }
            | ApiType::InspectMessage { .. }
            | ApiType::NonReplicatedQuery { .. } => (),
            ApiType::Update {
                outgoing_request, ..
            }
            | ApiType::ReplyCallback {
                outgoing_request, ..
            }
            | ApiType::RejectCallback {
                outgoing_request, ..
            } => {
                if let Some(outgoing_request) = outgoing_request.take() {
                    self.system_state_accessor
                        .canister_cycles_refund(outgoing_request.take_cycles());
                }
            }
        }
        if let Some(err) = wasm_run_error
            .cloned()
            .or_else(|| self.execution_error.take())
        {
            // Return allocated memory in case of failed message execution.
            self.memory_usage
                .deallocate_memory(self.memory_usage.allocated_memory);
            return Err(err);
        }
        match &mut self.api_type {
            ApiType::Start { .. }
            | ApiType::Init { .. }
            | ApiType::PreUpgrade { .. }
            | ApiType::Cleanup { .. }
            | ApiType::Heartbeat { .. } => Ok(None),
            ApiType::InspectMessage {
                message_accepted, ..
            } => {
                if *message_accepted {
                    Ok(None)
                } else {
                    Err(HypervisorError::MessageRejected)
                }
            }
            ApiType::Update {
                response_status, ..
            }
            | ApiType::ReplicatedQuery {
                response_status, ..
            }
            | ApiType::NonReplicatedQuery {
                response_status, ..
            }
            | ApiType::ReplyCallback {
                response_status, ..
            }
            | ApiType::RejectCallback {
                response_status, ..
            } => match response_status {
                ResponseStatus::JustRepliedWith(ref mut result) => Ok(result.take()),
                _ => Ok(None),
            },
        }
    }
pub fn take_execution_result ( & mut self , wasm_run_error : Option < & HypervisorError > , ) -> HypervisorResult < Option < WasmResult > > { match & mut self . api_type { ApiType :: Start { .. } | ApiType :: Init { .. } | ApiType :: Heartbeat { .. } | ApiType :: Cleanup { .. } | ApiType :: ReplicatedQuery { .. } | ApiType :: PreUpgrade { .. } | ApiType :: InspectMessage { .. } | ApiType :: NonReplicatedQuery { .. } => ( ) , ApiType :: Update { outgoing_request , .. } | ApiType :: ReplyCallback { outgoing_request , .. } | ApiType :: RejectCallback { outgoing_request , .. } => { if let Some ( outgoing_request ) = outgoing_request . take ( ) { self . system_state_accessor . canister_cycles_refund ( outgoing_request . take_cycles ( ) ) ; } } } if let Some ( err ) = wasm_run_error . cloned ( ) . or_else ( | | self . execution_error . take ( ) ) { // Return allocated memory in case of failed message execution. self . memory_usage . deallocate_memory ( self . memory_usage . allocated_memory ) ; return Err ( err ) ; } match & mut self . api_type { ApiType :: Start { .. } | ApiType :: Init { .. } | ApiType :: PreUpgrade { .. } | ApiType :: Cleanup { .. } | ApiType :: Heartbeat { .. } => Ok ( None ) , ApiType :: InspectMessage { message_accepted , .. } => { if * message_accepted { Ok ( None ) } else { Err ( HypervisorError :: MessageRejected ) } } ApiType :: Update { response_status , .. } | ApiType :: ReplicatedQuery { response_status , .. } | ApiType :: NonReplicatedQuery { response_status , .. } | ApiType :: ReplyCallback { response_status , .. } | ApiType :: RejectCallback { response_status , .. } => match response_status { ResponseStatus :: JustRepliedWith ( ref mut result ) => Ok ( result . take ( ) ) , _ => Ok ( None ) , } , } }
Gets the result of execution, assuming there is no error from
running the canister.
Gets the result of execution assuming there is no error from running the canister .
&mut self
wasm_run_error
Option<&HypervisorError>
&mut self
wasm_run_error
Option<&HypervisorError>