fn handle_response_with_query_origin(
        &mut self,
        mut canister: CanisterState,
        call_context_id: CallContextId,
        execution_result: Result<Option<WasmResult>, HypervisorError>,
    ) -> Option<Result<WasmResult, UserError>> {
        let canister_id = canister.canister_id();
        // As we have executed a request on the canister earlier, it must
        // contain a call context manager hence the following should not fail.
        let call_context_manager = canister
            .system_state
            .call_context_manager_mut()
            .unwrap_or_else(|| {
                fatal!(
                    self.log,
                    "Canister {}: Expected to find a CallContextManager",
                    canister_id
                )
            });

        use CallContextAction::*;
        match call_context_manager.on_canister_result(call_context_id, execution_result) {
            Reply { payload, refund } => {
                if !refund.is_zero() {
                    warn!(
                        self.log,
                        "[EXC-BUG] No cycles are refunded in a response to a query call."
                    );
                }
                Some(Ok(WasmResult::Reply(payload)))
            }
            Reject { payload, refund } => {
                if !refund.is_zero() {
                    warn!(
                        self.log,
                        "[EXC-BUG] No cycles are refunded in a response to a query call."
                    );
                }
                Some(Ok(WasmResult::Reject(payload)))
            }
            NoResponse { refund } => {
                if !refund.is_zero() {
                    warn!(
                        self.log,
                        "[EXC-BUG] No cycles are refunded in a response to a query call."
                    );
                }
                Some(Err(UserError::new(
                    ErrorCode::CanisterDidNotReply,
                    format!("Canister {} did not produce a response", canister_id),
                )))
            }
            Fail { error, refund } => {
                if !refund.is_zero() {
                    warn!(
                        self.log,
                        "[EXC-BUG] No cycles are refunded in a response to a query call."
                    );
                }
                Some(Err(error.into_user_error(&canister.canister_id())))
            }
            // No response available and there are still outstanding
            // callbacks.  Enqueue any produced requests and continue
            // processing the query context.
            NotYetResponded => match self.enqueue_requests(&mut canister) {
                EnqueueRequestsResult::LoopDetected => Some(Err(UserError::new(
                    ErrorCode::InterCanisterQueryLoopDetected,
                    LOOP_DETECTED_ERROR_MSG.to_string(),
                ))),
                EnqueueRequestsResult::NoMessages | EnqueueRequestsResult::MessagesEnqueued => {
                    self.canisters.insert(canister.canister_id(), canister);
                    None
                }
            },
            // This state indicates that the canister produced a
            // response or reject earlier and we continued to keep
            // executing it.  This should not happen as once the
            // canister has produced a response, we drop its state and
            // do not process further messages on it.
            AlreadyResponded => fatal!(
                self.log,
                "Canister {}: Should not be possible to keep executing after producing a response",
                canister_id
            ),
        }
    }
/// Handles results from executing a response on a canister where the sender
/// of the request was an end-user. This means that this is the very first
/// canister in the inter-canister query call graph hence if it produces a
/// response, it can be returned and the rest of the call graph abandoned.
Handles results from executing a response on a canister where the sender
of the request was an end-user. This means that this is the very first
canister in the inter-canister query call graph hence if it produces a
response, it can be returned and the rest of the call graph abandoned.
Handles results from executing a response on a canister where the sender of the request was an end - user . This means that this is the very first canister in the inter - canister query call graph hence if it produces a response it can be returned and the rest of the call graph abandoned .
fn handle_response_with_query_origin(
        &mut self,
        mut canister: CanisterState,
        call_context_id: CallContextId,
        execution_result: Result<Option<WasmResult>, HypervisorError>,
    ) -> Option<Result<WasmResult, UserError>> {
        let canister_id = canister.canister_id();
        // As we have executed a request on the canister earlier, it must
        // contain a call context manager hence the following should not fail.
        let call_context_manager = canister
            .system_state
            .call_context_manager_mut()
            .unwrap_or_else(|| {
                fatal!(
                    self.log,
                    "Canister {}: Expected to find a CallContextManager",
                    canister_id
                )
            });
        use CallContextAction::*;
        match call_context_manager.on_canister_result(call_context_id, execution_result) {
            Reply { payload, refund } => {
                if !refund.is_zero() {
                    warn!(
                        self.log,
                        "[EXC-BUG] No cycles are refunded in a response to a query call."
                    );
                }
                Some(Ok(WasmResult::Reply(payload)))
            }
            Reject { payload, refund } => {
                if !refund.is_zero() {
                    warn!(
                        self.log,
                        "[EXC-BUG] No cycles are refunded in a response to a query call."
                    );
                }
                Some(Ok(WasmResult::Reject(payload)))
            }
            NoResponse { refund } => {
                if !refund.is_zero() {
                    warn!(
                        self.log,
                        "[EXC-BUG] No cycles are refunded in a response to a query call."
                    );
                }
                Some(Err(UserError::new(
                    ErrorCode::CanisterDidNotReply,
                    format!("Canister {} did not produce a response", canister_id),
                )))
            }
            Fail { error, refund } => {
                if !refund.is_zero() {
                    warn!(
                        self.log,
                        "[EXC-BUG] No cycles are refunded in a response to a query call."
                    );
                }
                Some(Err(error.into_user_error(&canister.canister_id())))
            }
            // No response available and there are still outstanding
            // callbacks.  Enqueue any produced requests and continue
            // processing the query context.
            NotYetResponded => match self.enqueue_requests(&mut canister) {
                EnqueueRequestsResult::LoopDetected => Some(Err(UserError::new(
                    ErrorCode::InterCanisterQueryLoopDetected,
                    LOOP_DETECTED_ERROR_MSG.to_string(),
                ))),
                EnqueueRequestsResult::NoMessages | EnqueueRequestsResult::MessagesEnqueued => {
                    self.canisters.insert(canister.canister_id(), canister);
                    None
                }
            },
            // This state indicates that the canister produced a
            // response or reject earlier and we continued to keep
            // executing it.  This should not happen as once the
            // canister has produced a response, we drop its state and
            // do not process further messages on it.
            AlreadyResponded => fatal!(
                self.log,
                "Canister {}: Should not be possible to keep executing after producing a response",
                canister_id
            ),
        }
    }
fn handle_response_with_query_origin ( & mut self , mut canister : CanisterState , call_context_id : CallContextId , execution_result : Result < Option < WasmResult > , HypervisorError > , ) -> Option < Result < WasmResult , UserError > > { let canister_id = canister . canister_id ( ) ; // As we have executed a request on the canister earlier, it must // contain a call context manager hence the following should not fail. let call_context_manager = canister . system_state . call_context_manager_mut ( ) . unwrap_or_else ( | | { fatal ! ( self log " " canister_id ) } ) ; use CallContextAction :: * ; match call_context_manager . on_canister_result ( call_context_id , execution_result ) { Reply { payload , refund } => { if ! refund . is_zero ( ) { warn ! ( self log " " ) ; } Some ( Ok ( WasmResult :: Reply ( payload ) ) ) } Reject { payload , refund } => { if ! refund . is_zero ( ) { warn ! ( self log " " ) ; } Some ( Ok ( WasmResult :: Reject ( payload ) ) ) } NoResponse { refund } => { if ! refund . is_zero ( ) { warn ! ( self log " " ) ; } Some ( Err ( UserError :: new ( ErrorCode :: CanisterDidNotReply , format ! ( " " canister_id ) , ) ) ) } Fail { error , refund } => { if ! refund . is_zero ( ) { warn ! ( self log " " ) ; } Some ( Err ( error . into_user_error ( & canister . canister_id ( ) ) ) ) } // No response available and there are still outstanding // callbacks.  Enqueue any produced requests and continue // processing the query context. NotYetResponded => match self . enqueue_requests ( & mut canister ) { EnqueueRequestsResult :: LoopDetected => Some ( Err ( UserError :: new ( ErrorCode :: InterCanisterQueryLoopDetected , LOOP_DETECTED_ERROR_MSG . to_string ( ) , ) ) ) , EnqueueRequestsResult :: NoMessages | EnqueueRequestsResult :: MessagesEnqueued => { self . canisters . insert ( canister . canister_id ( ) , canister ) ; None } } , // This state indicates that the canister produced a // response or reject earlier and we continued to keep // executing it.  This should not happen as once the // canister has produced a response, we drop its state and // do not process further messages on it. AlreadyResponded => fatal ! ( self log " " canister_id ) , } }
Handles results from executing a response on a canister where the sender
of the request was an end-user.
Handles results from executing a response on a canister where the sender of the request was an end - user .
&mut self
canister
CanisterState
call_context_id
CallContextId
execution_result
Result<Option<WasmResult>, HypervisorError>
&mut self
canister
CanisterState
call_context_id
CallContextId
execution_result
Result<Option<WasmResult>, HypervisorError>