// Code generated by "enumer -type ReadOnlyMode -trimprefix ReadOnly -transform=lower"; DO NOT EDIT. package modbus import ( "fmt" "strings" ) const _ReadOnlyModeName = "falsedenytrue" var _ReadOnlyModeIndex = [...]uint8{0, 5, 9, 13} const _ReadOnlyModeLowerName = "falsedenytrue" func (i ReadOnlyMode) String() string { if i < 0 || i >= ReadOnlyMode(len(_ReadOnlyModeIndex)-1) { return fmt.Sprintf("ReadOnlyMode(%d)", i) } return _ReadOnlyModeName[_ReadOnlyModeIndex[i]:_ReadOnlyModeIndex[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 _ReadOnlyModeNoOp() { var x [1]struct{} _ = x[ReadOnlyFalse-(0)] _ = x[ReadOnlyDeny-(1)] _ = x[ReadOnlyTrue-(2)] } var _ReadOnlyModeValues = []ReadOnlyMode{ReadOnlyFalse, ReadOnlyDeny, ReadOnlyTrue} var _ReadOnlyModeNameToValueMap = map[string]ReadOnlyMode{ _ReadOnlyModeName[0:5]: ReadOnlyFalse, _ReadOnlyModeLowerName[0:5]: ReadOnlyFalse, _ReadOnlyModeName[5:9]: ReadOnlyDeny, _ReadOnlyModeLowerName[5:9]: ReadOnlyDeny, _ReadOnlyModeName[9:13]: ReadOnlyTrue, _ReadOnlyModeLowerName[9:13]: ReadOnlyTrue, } var _ReadOnlyModeNames = []string{ _ReadOnlyModeName[0:5], _ReadOnlyModeName[5:9], _ReadOnlyModeName[9:13], } // ReadOnlyModeString retrieves an enum value from the enum constants string name. // Throws an error if the param is not part of the enum. func ReadOnlyModeString(s string) (ReadOnlyMode, error) { if val, ok := _ReadOnlyModeNameToValueMap[s]; ok { return val, nil } if val, ok := _ReadOnlyModeNameToValueMap[strings.ToLower(s)]; ok { return val, nil } switch s { case "", "0": return ReadOnlyFalse, nil case "1": return ReadOnlyTrue, nil } return 0, fmt.Errorf("%s does not belong to ReadOnlyMode values", s) } // ReadOnlyModeValues returns all values of the enum func ReadOnlyModeValues() []ReadOnlyMode { return _ReadOnlyModeValues } // ReadOnlyModeStrings returns a slice of all String values of the enum func ReadOnlyModeStrings() []string { strs := make([]string, len(_ReadOnlyModeNames)) copy(strs, _ReadOnlyModeNames) return strs } // IsAReadOnlyMode returns "true" if the value is listed in the enum definition. "false" otherwise func (i ReadOnlyMode) IsAReadOnlyMode() bool { for _, v := range _ReadOnlyModeValues { if i == v { return true } } return false }