90 lines
2.3 KiB
Go
90 lines
2.3 KiB
Go
// Code generated by "enumer -type GpioType -trimprefix GpioType -transform=lower -text"; DO NOT EDIT.
|
|
|
|
package plugin
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
const _GpioTypeName = "readwrite"
|
|
|
|
var _GpioTypeIndex = [...]uint8{0, 4, 9}
|
|
|
|
const _GpioTypeLowerName = "readwrite"
|
|
|
|
func (i GpioType) String() string {
|
|
if i < 0 || i >= GpioType(len(_GpioTypeIndex)-1) {
|
|
return fmt.Sprintf("GpioType(%d)", i)
|
|
}
|
|
return _GpioTypeName[_GpioTypeIndex[i]:_GpioTypeIndex[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 _GpioTypeNoOp() {
|
|
var x [1]struct{}
|
|
_ = x[GpioTypeRead-(0)]
|
|
_ = x[GpioTypeWrite-(1)]
|
|
}
|
|
|
|
var _GpioTypeValues = []GpioType{GpioTypeRead, GpioTypeWrite}
|
|
|
|
var _GpioTypeNameToValueMap = map[string]GpioType{
|
|
_GpioTypeName[0:4]: GpioTypeRead,
|
|
_GpioTypeLowerName[0:4]: GpioTypeRead,
|
|
_GpioTypeName[4:9]: GpioTypeWrite,
|
|
_GpioTypeLowerName[4:9]: GpioTypeWrite,
|
|
}
|
|
|
|
var _GpioTypeNames = []string{
|
|
_GpioTypeName[0:4],
|
|
_GpioTypeName[4:9],
|
|
}
|
|
|
|
// GpioTypeString retrieves an enum value from the enum constants string name.
|
|
// Throws an error if the param is not part of the enum.
|
|
func GpioTypeString(s string) (GpioType, error) {
|
|
if val, ok := _GpioTypeNameToValueMap[s]; ok {
|
|
return val, nil
|
|
}
|
|
|
|
if val, ok := _GpioTypeNameToValueMap[strings.ToLower(s)]; ok {
|
|
return val, nil
|
|
}
|
|
return 0, fmt.Errorf("%s does not belong to GpioType values", s)
|
|
}
|
|
|
|
// GpioTypeValues returns all values of the enum
|
|
func GpioTypeValues() []GpioType {
|
|
return _GpioTypeValues
|
|
}
|
|
|
|
// GpioTypeStrings returns a slice of all String values of the enum
|
|
func GpioTypeStrings() []string {
|
|
strs := make([]string, len(_GpioTypeNames))
|
|
copy(strs, _GpioTypeNames)
|
|
return strs
|
|
}
|
|
|
|
// IsAGpioType returns "true" if the value is listed in the enum definition. "false" otherwise
|
|
func (i GpioType) IsAGpioType() bool {
|
|
for _, v := range _GpioTypeValues {
|
|
if i == v {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
// MarshalText implements the encoding.TextMarshaler interface for GpioType
|
|
func (i GpioType) MarshalText() ([]byte, error) {
|
|
return []byte(i.String()), nil
|
|
}
|
|
|
|
// UnmarshalText implements the encoding.TextUnmarshaler interface for GpioType
|
|
func (i *GpioType) UnmarshalText(text []byte) error {
|
|
var err error
|
|
*i, err = GpioTypeString(string(text))
|
|
return err
|
|
}
|