pub fn build(self) -> Result<ExecutionResult, ExecutionResultBuilderError> {
        let mut error: Option<error::Error> = None;
        let mut transfers = self.transfers();
        let cost = self.total_cost();

        let mut journal = match self.payment_execution_result {
            Some(result @ ExecutionResult::Failure { .. }) => return Ok(result),
            Some(ExecutionResult::Success {
                execution_journal, ..
            }) => execution_journal,
            None => return Err(ExecutionResultBuilderError::MissingPaymentExecutionResult),
        };

        // session_code_spec_3: only include session exec effects if there is no session
        // exec error
        match self.session_execution_result {
            Some(ExecutionResult::Failure {
                error: session_error,
                transfers: session_transfers,
                execution_journal: _,
                cost: _,
            }) => {
                error = Some(session_error);
                transfers = session_transfers;
            }
            Some(ExecutionResult::Success {
                execution_journal, ..
            }) => journal.extend(execution_journal.into_iter()),
            None => return Err(ExecutionResultBuilderError::MissingSessionExecutionResult),
        };

        match self.finalize_execution_result {
            Some(ExecutionResult::Failure { .. }) => {
                // payment_code_spec_5_a: Finalization Error should only ever be raised here
                return Ok(ExecutionResult::precondition_failure(
                    error::Error::Finalization,
                ));
            }
            Some(ExecutionResult::Success {
                execution_journal, ..
            }) => journal.extend(execution_journal.into_iter()),
            None => return Err(ExecutionResultBuilderError::MissingFinalizeExecutionResult),
        }

        match error {
            None => Ok(ExecutionResult::Success {
                transfers,
                cost,
                execution_journal: journal,
            }),
            Some(error) => Ok(ExecutionResult::Failure {
                error,
                transfers,
                cost,
                execution_journal: journal,
            }),
        }
    }
/// Builds a final [`ExecutionResult`] based on session result, payment result and a
/// finalization result.
Builds a final [`ExecutionResult`] based on session result, payment result and a
finalization result.
Builds a final [ ` ExecutionResult ` ] based on session result payment result and a finalization result .
pub fn build(self) -> Result<ExecutionResult, ExecutionResultBuilderError> {
        let mut error: Option<error::Error> = None;
        let mut transfers = self.transfers();
        let cost = self.total_cost();
        let mut journal = match self.payment_execution_result {
            Some(result @ ExecutionResult::Failure { .. }) => return Ok(result),
            Some(ExecutionResult::Success {
                execution_journal, ..
            }) => execution_journal,
            None => return Err(ExecutionResultBuilderError::MissingPaymentExecutionResult),
        };
        // session_code_spec_3: only include session exec effects if there is no session
        // exec error
        match self.session_execution_result {
            Some(ExecutionResult::Failure {
                error: session_error,
                transfers: session_transfers,
                execution_journal: _,
                cost: _,
            }) => {
                error = Some(session_error);
                transfers = session_transfers;
            }
            Some(ExecutionResult::Success {
                execution_journal, ..
            }) => journal.extend(execution_journal.into_iter()),
            None => return Err(ExecutionResultBuilderError::MissingSessionExecutionResult),
        };
        match self.finalize_execution_result {
            Some(ExecutionResult::Failure { .. }) => {
                // payment_code_spec_5_a: Finalization Error should only ever be raised here
                return Ok(ExecutionResult::precondition_failure(
                    error::Error::Finalization,
                ));
            }
            Some(ExecutionResult::Success {
                execution_journal, ..
            }) => journal.extend(execution_journal.into_iter()),
            None => return Err(ExecutionResultBuilderError::MissingFinalizeExecutionResult),
        }
        match error {
            None => Ok(ExecutionResult::Success {
                transfers,
                cost,
                execution_journal: journal,
            }),
            Some(error) => Ok(ExecutionResult::Failure {
                error,
                transfers,
                cost,
                execution_journal: journal,
            }),
        }
    }
pub fn build ( self ) -> Result < ExecutionResult , ExecutionResultBuilderError > { let mut error : Option < error :: Error > = None ; let mut transfers = self . transfers ( ) ; let cost = self . total_cost ( ) ; let mut journal = match self . payment_execution_result { Some ( result @ ExecutionResult :: Failure { .. } ) => return Ok ( result ) , Some ( ExecutionResult :: Success { execution_journal , .. } ) => execution_journal , None => return Err ( ExecutionResultBuilderError :: MissingPaymentExecutionResult ) , } ; // session_code_spec_3: only include session exec effects if there is no session // exec error match self . session_execution_result { Some ( ExecutionResult :: Failure { error : session_error , transfers : session_transfers , execution_journal : _ , cost : _ , } ) => { error = Some ( session_error ) ; transfers = session_transfers ; } Some ( ExecutionResult :: Success { execution_journal , .. } ) => journal . extend ( execution_journal . into_iter ( ) ) , None => return Err ( ExecutionResultBuilderError :: MissingSessionExecutionResult ) , } ; match self . finalize_execution_result { Some ( ExecutionResult :: Failure { .. } ) => { // payment_code_spec_5_a: Finalization Error should only ever be raised here return Ok ( ExecutionResult :: precondition_failure ( error :: Error :: Finalization , ) ) ; } Some ( ExecutionResult :: Success { execution_journal , .. } ) => journal . extend ( execution_journal . into_iter ( ) ) , None => return Err ( ExecutionResultBuilderError :: MissingFinalizeExecutionResult ) , } match error { None => Ok ( ExecutionResult :: Success { transfers , cost , execution_journal : journal , } ) , Some ( error ) => Ok ( ExecutionResult :: Failure { error , transfers , cost , execution_journal : journal , } ) , } }
Builds a final [`ExecutionResult`] based on session result, payment result and a
finalization result.
Builds a final [ ` ExecutionResult ` ] based on session result payment result and a finalization result .
self
self