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

package runtime

import (
	"fmt"
)

const _MachineStageName = "unknownbootinginstallingmaintenancerunningrebootingshutting downresettingupgrading"

var _MachineStageIndex = [...]uint8{0, 7, 14, 24, 35, 42, 51, 64, 73, 82}

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

var _MachineStageValues = []MachineStage{0, 1, 2, 3, 4, 5, 6, 7, 8}

var _MachineStageNameToValueMap = map[string]MachineStage{
	_MachineStageName[0:7]:   0,
	_MachineStageName[7:14]:  1,
	_MachineStageName[14:24]: 2,
	_MachineStageName[24:35]: 3,
	_MachineStageName[35:42]: 4,
	_MachineStageName[42:51]: 5,
	_MachineStageName[51:64]: 6,
	_MachineStageName[64:73]: 7,
	_MachineStageName[73:82]: 8,
}

// MachineStageString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func MachineStageString(s string) (MachineStage, error) {
	if val, ok := _MachineStageNameToValueMap[s]; ok {
		return val, nil
	}
	return 0, fmt.Errorf("%s does not belong to MachineStage values", s)
}

// MachineStageValues returns all values of the enum
func MachineStageValues() []MachineStage {
	return _MachineStageValues
}

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

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

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