pub fn execute_request(&self, request: Request, app_name: Option<ApplicationName>) -> Response {
        let opcode = request.header.opcode;
        let header = request.header;

        macro_rules! unwrap_or_else_return {
            ($result:expr) => {
                match $result {
                    Ok(value) => value,
                    Err(status) => return Response::from_request_header(header, status),
                }
            };
        }

        match unwrap_or_else_return!(self.converter.body_to_operation(request.body, opcode)) {
            NativeOperation::ListProviders(op_list_providers) => {
                let result =
                    unwrap_or_else_return!(self.provider.list_providers(op_list_providers));
                self.result_to_response(NativeResult::ListProviders(result), header)
            }
            NativeOperation::ListOpcodes(op_list_opcodes) => {
                let result = unwrap_or_else_return!(self.provider.list_opcodes(op_list_opcodes));
                self.result_to_response(NativeResult::ListOpcodes(result), header)
            }
            NativeOperation::Ping(op_ping) => {
                let result = unwrap_or_else_return!(self.provider.ping(op_ping));
                self.result_to_response(NativeResult::Ping(result), header)
            }
            NativeOperation::PsaGenerateKey(op_generate_key) => {
                let app_name =
                    unwrap_or_else_return!(app_name.ok_or(ResponseStatus::NotAuthenticated));
                let result = unwrap_or_else_return!(self
                    .provider
                    .psa_generate_key(app_name, op_generate_key));
                self.result_to_response(NativeResult::PsaGenerateKey(result), header)
            }
            NativeOperation::PsaImportKey(op_import_key) => {
                let app_name =
                    unwrap_or_else_return!(app_name.ok_or(ResponseStatus::NotAuthenticated));
                let result =
                    unwrap_or_else_return!(self.provider.psa_import_key(app_name, op_import_key));
                self.result_to_response(NativeResult::PsaImportKey(result), header)
            }
            NativeOperation::PsaExportPublicKey(op_export_public_key) => {
                let app_name =
                    unwrap_or_else_return!(app_name.ok_or(ResponseStatus::NotAuthenticated));
                let result = unwrap_or_else_return!(self
                    .provider
                    .psa_export_public_key(app_name, op_export_public_key));
                self.result_to_response(NativeResult::PsaExportPublicKey(result), header)
            }
            NativeOperation::PsaDestroyKey(op_destroy_key) => {
                let app_name =
                    unwrap_or_else_return!(app_name.ok_or(ResponseStatus::NotAuthenticated));
                let result =
                    unwrap_or_else_return!(self.provider.psa_destroy_key(app_name, op_destroy_key));
                self.result_to_response(NativeResult::PsaDestroyKey(result), header)
            }
            NativeOperation::PsaSignHash(op_sign_hash) => {
                let app_name =
                    unwrap_or_else_return!(app_name.ok_or(ResponseStatus::NotAuthenticated));
                let result =
                    unwrap_or_else_return!(self.provider.psa_sign_hash(app_name, op_sign_hash));
                self.result_to_response(NativeResult::PsaSignHash(result), header)
            }
            NativeOperation::PsaVerifyHash(op_verify_hash) => {
                let app_name =
                    unwrap_or_else_return!(app_name.ok_or(ResponseStatus::NotAuthenticated));
                let result =
                    unwrap_or_else_return!(self.provider.psa_verify_hash(app_name, op_verify_hash));
                self.result_to_response(NativeResult::PsaVerifyHash(result), header)
            }
        }
    }
/// Unmarshall the request body, pass the operation to the provider and marshall
/// the result back.
///
/// If any of the steps fails, a response containing an appropriate status code is
/// returned.
Unmarshall the request body, pass the operation to the provider and marshall
the result back.

If any of the steps fails, a response containing an appropriate status code is
returned.
Unmarshall the request body pass the operation to the provider and marshall the result back . If any of the steps fails a response containing an appropriate status code is returned .
pub fn execute_request(&self, request: Request, app_name: Option<ApplicationName>) -> Response {
        let opcode = request.header.opcode;
        let header = request.header;
        macro_rules! unwrap_or_else_return {
            ($result:expr) => {
                match $result {
                    Ok(value) => value,
                    Err(status) => return Response::from_request_header(header, status),
                }
            };
        }
        match unwrap_or_else_return!(self.converter.body_to_operation(request.body, opcode)) {
            NativeOperation::ListProviders(op_list_providers) => {
                let result =
                    unwrap_or_else_return!(self.provider.list_providers(op_list_providers));
                self.result_to_response(NativeResult::ListProviders(result), header)
            }
            NativeOperation::ListOpcodes(op_list_opcodes) => {
                let result = unwrap_or_else_return!(self.provider.list_opcodes(op_list_opcodes));
                self.result_to_response(NativeResult::ListOpcodes(result), header)
            }
            NativeOperation::Ping(op_ping) => {
                let result = unwrap_or_else_return!(self.provider.ping(op_ping));
                self.result_to_response(NativeResult::Ping(result), header)
            }
            NativeOperation::PsaGenerateKey(op_generate_key) => {
                let app_name =
                    unwrap_or_else_return!(app_name.ok_or(ResponseStatus::NotAuthenticated));
                let result = unwrap_or_else_return!(self
                    .provider
                    .psa_generate_key(app_name, op_generate_key));
                self.result_to_response(NativeResult::PsaGenerateKey(result), header)
            }
            NativeOperation::PsaImportKey(op_import_key) => {
                let app_name =
                    unwrap_or_else_return!(app_name.ok_or(ResponseStatus::NotAuthenticated));
                let result =
                    unwrap_or_else_return!(self.provider.psa_import_key(app_name, op_import_key));
                self.result_to_response(NativeResult::PsaImportKey(result), header)
            }
            NativeOperation::PsaExportPublicKey(op_export_public_key) => {
                let app_name =
                    unwrap_or_else_return!(app_name.ok_or(ResponseStatus::NotAuthenticated));
                let result = unwrap_or_else_return!(self
                    .provider
                    .psa_export_public_key(app_name, op_export_public_key));
                self.result_to_response(NativeResult::PsaExportPublicKey(result), header)
            }
            NativeOperation::PsaDestroyKey(op_destroy_key) => {
                let app_name =
                    unwrap_or_else_return!(app_name.ok_or(ResponseStatus::NotAuthenticated));
                let result =
                    unwrap_or_else_return!(self.provider.psa_destroy_key(app_name, op_destroy_key));
                self.result_to_response(NativeResult::PsaDestroyKey(result), header)
            }
            NativeOperation::PsaSignHash(op_sign_hash) => {
                let app_name =
                    unwrap_or_else_return!(app_name.ok_or(ResponseStatus::NotAuthenticated));
                let result =
                    unwrap_or_else_return!(self.provider.psa_sign_hash(app_name, op_sign_hash));
                self.result_to_response(NativeResult::PsaSignHash(result), header)
            }
            NativeOperation::PsaVerifyHash(op_verify_hash) => {
                let app_name =
                    unwrap_or_else_return!(app_name.ok_or(ResponseStatus::NotAuthenticated));
                let result =
                    unwrap_or_else_return!(self.provider.psa_verify_hash(app_name, op_verify_hash));
                self.result_to_response(NativeResult::PsaVerifyHash(result), header)
            }
        }
    }
pub fn execute_request ( & self , request : Request , app_name : Option < ApplicationName > ) -> Response { let opcode = request . header . opcode ; let header = request . header ; macro_rules! unwrap_or_else_return { ( $result : expr ) => { match $result { Ok ( value ) value Err ( status ) return Response from_request_header ( header status ) } } ; } match unwrap_or_else_return ! ( self converter body_to_operation ( request body opcode ) ) { NativeOperation :: ListProviders ( op_list_providers ) => { let result = unwrap_or_else_return ! ( self provider list_providers ( op_list_providers ) ) ; self . result_to_response ( NativeResult :: ListProviders ( result ) , header ) } NativeOperation :: ListOpcodes ( op_list_opcodes ) => { let result = unwrap_or_else_return ! ( self provider list_opcodes ( op_list_opcodes ) ) ; self . result_to_response ( NativeResult :: ListOpcodes ( result ) , header ) } NativeOperation :: Ping ( op_ping ) => { let result = unwrap_or_else_return ! ( self provider ping ( op_ping ) ) ; self . result_to_response ( NativeResult :: Ping ( result ) , header ) } NativeOperation :: PsaGenerateKey ( op_generate_key ) => { let app_name = unwrap_or_else_return ! ( app_name ok_or ( ResponseStatus NotAuthenticated ) ) ; let result = unwrap_or_else_return ! ( self provider psa_generate_key ( app_name op_generate_key ) ) ; self . result_to_response ( NativeResult :: PsaGenerateKey ( result ) , header ) } NativeOperation :: PsaImportKey ( op_import_key ) => { let app_name = unwrap_or_else_return ! ( app_name ok_or ( ResponseStatus NotAuthenticated ) ) ; let result = unwrap_or_else_return ! ( self provider psa_import_key ( app_name op_import_key ) ) ; self . result_to_response ( NativeResult :: PsaImportKey ( result ) , header ) } NativeOperation :: PsaExportPublicKey ( op_export_public_key ) => { let app_name = unwrap_or_else_return ! ( app_name ok_or ( ResponseStatus NotAuthenticated ) ) ; let result = unwrap_or_else_return ! ( self provider psa_export_public_key ( app_name op_export_public_key ) ) ; self . result_to_response ( NativeResult :: PsaExportPublicKey ( result ) , header ) } NativeOperation :: PsaDestroyKey ( op_destroy_key ) => { let app_name = unwrap_or_else_return ! ( app_name ok_or ( ResponseStatus NotAuthenticated ) ) ; let result = unwrap_or_else_return ! ( self provider psa_destroy_key ( app_name op_destroy_key ) ) ; self . result_to_response ( NativeResult :: PsaDestroyKey ( result ) , header ) } NativeOperation :: PsaSignHash ( op_sign_hash ) => { let app_name = unwrap_or_else_return ! ( app_name ok_or ( ResponseStatus NotAuthenticated ) ) ; let result = unwrap_or_else_return ! ( self provider psa_sign_hash ( app_name op_sign_hash ) ) ; self . result_to_response ( NativeResult :: PsaSignHash ( result ) , header ) } NativeOperation :: PsaVerifyHash ( op_verify_hash ) => { let app_name = unwrap_or_else_return ! ( app_name ok_or ( ResponseStatus NotAuthenticated ) ) ; let result = unwrap_or_else_return ! ( self provider psa_verify_hash ( app_name op_verify_hash ) ) ; self . result_to_response ( NativeResult :: PsaVerifyHash ( result ) , header ) } } }
Unmarshall the request body, pass the operation to the provider and marshall
the result back.
Unmarshall the request body pass the operation to the provider and marshall the result back .
&self
request
Request
app_name
Option<ApplicationName>
&self
request
Request
app_name
Option<ApplicationName>