// Code generated by "enumer -type=KernelModuleState -linecomment -text"; DO NOT EDIT.

package runtime

import (
	"fmt"
	"strings"
)

const _KernelModuleStateName = "liveloadingunloadingbuilt-in"

var _KernelModuleStateIndex = [...]uint8{0, 4, 11, 20, 28}

const _KernelModuleStateLowerName = "liveloadingunloadingbuilt-in"

func (i KernelModuleState) String() string {
	if i < 0 || i >= KernelModuleState(len(_KernelModuleStateIndex)-1) {
		return fmt.Sprintf("KernelModuleState(%d)", i)
	}
	return _KernelModuleStateName[_KernelModuleStateIndex[i]:_KernelModuleStateIndex[i+1]]
}

// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
func _KernelModuleStateNoOp() {
	var x [1]struct{}
	_ = x[KernelModuleStateLive-(0)]
	_ = x[KernelModuleStateLoading-(1)]
	_ = x[KernelModuleStateUnloading-(2)]
	_ = x[KernelModuleStateBuiltin-(3)]
}

var _KernelModuleStateValues = []KernelModuleState{KernelModuleStateLive, KernelModuleStateLoading, KernelModuleStateUnloading, KernelModuleStateBuiltin}

var _KernelModuleStateNameToValueMap = map[string]KernelModuleState{
	_KernelModuleStateName[0:4]:        KernelModuleStateLive,
	_KernelModuleStateLowerName[0:4]:   KernelModuleStateLive,
	_KernelModuleStateName[4:11]:       KernelModuleStateLoading,
	_KernelModuleStateLowerName[4:11]:  KernelModuleStateLoading,
	_KernelModuleStateName[11:20]:      KernelModuleStateUnloading,
	_KernelModuleStateLowerName[11:20]: KernelModuleStateUnloading,
	_KernelModuleStateName[20:28]:      KernelModuleStateBuiltin,
	_KernelModuleStateLowerName[20:28]: KernelModuleStateBuiltin,
}

var _KernelModuleStateNames = []string{
	_KernelModuleStateName[0:4],
	_KernelModuleStateName[4:11],
	_KernelModuleStateName[11:20],
	_KernelModuleStateName[20:28],
}

// KernelModuleStateString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func KernelModuleStateString(s string) (KernelModuleState, error) {
	if val, ok := _KernelModuleStateNameToValueMap[s]; ok {
		return val, nil
	}

	if val, ok := _KernelModuleStateNameToValueMap[strings.ToLower(s)]; ok {
		return val, nil
	}
	return 0, fmt.Errorf("%s does not belong to KernelModuleState values", s)
}

// KernelModuleStateValues returns all values of the enum
func KernelModuleStateValues() []KernelModuleState {
	return _KernelModuleStateValues
}

// KernelModuleStateStrings returns a slice of all String values of the enum
func KernelModuleStateStrings() []string {
	strs := make([]string, len(_KernelModuleStateNames))
	copy(strs, _KernelModuleStateNames)
	return strs
}

// IsAKernelModuleState returns "true" if the value is listed in the enum definition. "false" otherwise
func (i KernelModuleState) IsAKernelModuleState() bool {
	for _, v := range _KernelModuleStateValues {
		if i == v {
			return true
		}
	}
	return false
}

// MarshalText implements the encoding.TextMarshaler interface for KernelModuleState
func (i KernelModuleState) MarshalText() ([]byte, error) {
	return []byte(i.String()), nil
}

// UnmarshalText implements the encoding.TextUnmarshaler interface for KernelModuleState
func (i *KernelModuleState) UnmarshalText(text []byte) error {
	var err error
	*i, err = KernelModuleStateString(string(text))
	return err
}
