// Code generated by go-enum DO NOT EDIT.
// Version: 0.5.8
// Revision: 3d844c8ecc59661ed7aa17bfd65727bc06a60ad8
// Build Date: 2023-09-18T14:55:21Z
// Built By: goreleaser

package kv

import (
	"fmt"
	"strings"
)

const (
	// DriverLegacy is a Driver of type legacy.
	DriverLegacy Driver = "legacy"
	// DriverBolt is a Driver of type bolt.
	DriverBolt Driver = "bolt"
	// DriverFile is a Driver of type file.
	DriverFile Driver = "file"
)

var ErrInvalidDriver = fmt.Errorf("not a valid Driver, try [%s]", strings.Join(_DriverNames, ", "))

var _DriverNames = []string{
	string(DriverLegacy),
	string(DriverBolt),
	string(DriverFile),
}

// DriverNames returns a list of possible string values of Driver.
func DriverNames() []string {
	tmp := make([]string, len(_DriverNames))
	copy(tmp, _DriverNames)
	return tmp
}

// DriverValues returns a list of the values for Driver
func DriverValues() []Driver {
	return []Driver{
		DriverLegacy,
		DriverBolt,
		DriverFile,
	}
}

// String implements the Stringer interface.
func (x Driver) String() string {
	return string(x)
}

// IsValid provides a quick way to determine if the typed value is
// part of the allowed enumerated values
func (x Driver) IsValid() bool {
	_, err := ParseDriver(string(x))
	return err == nil
}

var _DriverValue = map[string]Driver{
	"legacy": DriverLegacy,
	"bolt":   DriverBolt,
	"file":   DriverFile,
}

// ParseDriver attempts to convert a string to a Driver.
func ParseDriver(name string) (Driver, error) {
	if x, ok := _DriverValue[name]; ok {
		return x, nil
	}
	// Case insensitive parse, do a separate lookup to prevent unnecessary cost of lowercasing a string if we don't need to.
	if x, ok := _DriverValue[strings.ToLower(name)]; ok {
		return x, nil
	}
	return Driver(""), fmt.Errorf("%s is %w", name, ErrInvalidDriver)
}

// Set implements the Golang flag.Value interface func.
func (x *Driver) Set(val string) error {
	v, err := ParseDriver(val)
	*x = v
	return err
}

// Get implements the Golang flag.Getter interface func.
func (x *Driver) Get() interface{} {
	return *x
}

// Type implements the github.com/spf13/pFlag Value interface.
func (x *Driver) Type() string {
	return "Driver"
}
