// Code generated by smithy-go-codegen DO NOT EDIT.

package WrappedAwsCryptographyEncryptionSdkService

import (
	"context"

	"github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Wrappers"
	"github.com/aws/aws-encryption-sdk/releases/go/encryption-sdk/AwsCryptographyEncryptionSdkTypes"
	"github.com/aws/aws-encryption-sdk/releases/go/encryption-sdk/awscryptographyencryptionsdksmithygenerated"
)

type Shim struct {
	AwsCryptographyEncryptionSdkTypes.IAwsEncryptionSdkClient
	client *awscryptographyencryptionsdksmithygenerated.Client
}

func (_static *CompanionStruct_Default___) WrappedESDK(inputConfig AwsCryptographyEncryptionSdkTypes.AwsEncryptionSdkConfig) Wrappers.Result {
	var nativeConfig = awscryptographyencryptionsdksmithygenerated.AwsEncryptionSdkConfig_FromDafny(inputConfig)
	var nativeClient, nativeError = awscryptographyencryptionsdksmithygenerated.NewClient(nativeConfig)
	if nativeError != nil {
		return Wrappers.Companion_Result_.Create_Failure_(AwsCryptographyEncryptionSdkTypes.Companion_Error_.Create_Opaque_(nativeError))
	}
	return Wrappers.Companion_Result_.Create_Success_(&Shim{client: nativeClient})
}

func (shim *Shim) Encrypt(input AwsCryptographyEncryptionSdkTypes.EncryptInput) Wrappers.Result {
	var native_request = awscryptographyencryptionsdksmithygenerated.EncryptInput_FromDafny(input)
	var native_response, native_error = shim.client.Encrypt(context.Background(), native_request)
	if native_error != nil {
		return Wrappers.Companion_Result_.Create_Failure_(awscryptographyencryptionsdksmithygenerated.Error_ToDafny(native_error))
	}
	return Wrappers.Companion_Result_.Create_Success_(awscryptographyencryptionsdksmithygenerated.EncryptOutput_ToDafny(*native_response))
}

func (shim *Shim) Decrypt(input AwsCryptographyEncryptionSdkTypes.DecryptInput) Wrappers.Result {
	var native_request = awscryptographyencryptionsdksmithygenerated.DecryptInput_FromDafny(input)
	var native_response, native_error = shim.client.Decrypt(context.Background(), native_request)
	if native_error != nil {
		return Wrappers.Companion_Result_.Create_Failure_(awscryptographyencryptionsdksmithygenerated.Error_ToDafny(native_error))
	}
	return Wrappers.Companion_Result_.Create_Success_(awscryptographyencryptionsdksmithygenerated.DecryptOutput_ToDafny(*native_response))
}
