// 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 forwarder

import (
	"fmt"
	"strings"
)

const (
	// ModeDirect is a Mode of type Direct.
	ModeDirect Mode = iota
	// ModeClone is a Mode of type Clone.
	ModeClone
)

var ErrInvalidMode = fmt.Errorf("not a valid Mode, try [%s]", strings.Join(_ModeNames, ", "))

const _ModeName = "directclone"

var _ModeNames = []string{
	_ModeName[0:6],
	_ModeName[6:11],
}

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

// ModeValues returns a list of the values for Mode
func ModeValues() []Mode {
	return []Mode{
		ModeDirect,
		ModeClone,
	}
}

var _ModeMap = map[Mode]string{
	ModeDirect: _ModeName[0:6],
	ModeClone:  _ModeName[6:11],
}

// String implements the Stringer interface.
func (x Mode) String() string {
	if str, ok := _ModeMap[x]; ok {
		return str
	}
	return fmt.Sprintf("Mode(%d)", x)
}

// IsValid provides a quick way to determine if the typed value is
// part of the allowed enumerated values
func (x Mode) IsValid() bool {
	_, ok := _ModeMap[x]
	return ok
}

var _ModeValue = map[string]Mode{
	_ModeName[0:6]:                   ModeDirect,
	strings.ToLower(_ModeName[0:6]):  ModeDirect,
	_ModeName[6:11]:                  ModeClone,
	strings.ToLower(_ModeName[6:11]): ModeClone,
}

// ParseMode attempts to convert a string to a Mode.
func ParseMode(name string) (Mode, error) {
	if x, ok := _ModeValue[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 := _ModeValue[strings.ToLower(name)]; ok {
		return x, nil
	}
	return Mode(0), fmt.Errorf("%s is %w", name, ErrInvalidMode)
}

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

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

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