// Code generated by gen/main.go; DO NOT EDIT.

package touchid

/*
#cgo CFLAGS: -x objective-c -fmodules
#cgo LDFLAGS: -framework LocalAuthentication
#import <LocalAuthentication/LocalAuthentication.h>
#include "touchid.h"
*/
import "C"

import (
	"errors"
	"fmt"
)

// Policy represents an LAPolicy value.
type Policy C.int

const (
	PolicyDeviceOwnerAuthentication                          Policy = C.LAPolicyDeviceOwnerAuthentication
	PolicyDeviceOwnerAuthenticationWithBiometrics            Policy = C.LAPolicyDeviceOwnerAuthenticationWithBiometrics
	PolicyDeviceOwnerAuthenticationWithBiometricsOrCompanion Policy = C.LAPolicyDeviceOwnerAuthenticationWithBiometricsOrCompanion
	PolicyDeviceOwnerAuthenticationWithCompanion             Policy = C.LAPolicyDeviceOwnerAuthenticationWithCompanion
)

var (
	ErrAppCancel             = errors.New("app cancel")
	ErrAuthenticationFailed  = errors.New("authentication failed")
	ErrBiometryDisconnected  = errors.New("biometry disconnected")
	ErrBiometryLockout       = errors.New("biometry lockout")
	ErrBiometryNotAvailable  = errors.New("biometry not available")
	ErrBiometryNotEnrolled   = errors.New("biometry not enrolled")
	ErrBiometryNotPaired     = errors.New("biometry not paired")
	ErrCompanionNotAvailable = errors.New("companion not available")
	ErrInvalidContext        = errors.New("invalid context")
	ErrInvalidDimensions     = errors.New("invalid dimensions")
	ErrNotInteractive        = errors.New("not interactive")
	ErrPasscodeNotSet        = errors.New("passcode not set")
	ErrSystemCancel          = errors.New("system cancel")
	ErrUserCancel            = errors.New("user cancel")
	ErrUserFallback          = errors.New("user fallback")
)

func errorFromCode(code C.int) error {
	switch code {
	case C.TOUCHID_SUCCESS:
		return nil
	case C.LAErrorAppCancel:
		return ErrAppCancel
	case C.LAErrorAuthenticationFailed:
		return ErrAuthenticationFailed
	case C.LAErrorBiometryDisconnected:
		return ErrBiometryDisconnected
	case C.LAErrorBiometryLockout:
		return ErrBiometryLockout
	case C.LAErrorBiometryNotAvailable:
		return ErrBiometryNotAvailable
	case C.LAErrorBiometryNotEnrolled:
		return ErrBiometryNotEnrolled
	case C.LAErrorBiometryNotPaired:
		return ErrBiometryNotPaired
	case C.LAErrorCompanionNotAvailable:
		return ErrCompanionNotAvailable
	case C.LAErrorInvalidContext:
		return ErrInvalidContext
	case C.LAErrorInvalidDimensions:
		return ErrInvalidDimensions
	case C.LAErrorNotInteractive:
		return ErrNotInteractive
	case C.LAErrorPasscodeNotSet:
		return ErrPasscodeNotSet
	case C.LAErrorSystemCancel:
		return ErrSystemCancel
	case C.LAErrorUserCancel:
		return ErrUserCancel
	case C.LAErrorUserFallback:
		return ErrUserFallback
	default:
		return fmt.Errorf("unknown authentication error: %d", int(code))
	}
}
