talos/pkg/machinery/nethelpers/port_enumer.go
Andrey Smirnov a6b010a8b4
chore: update Go to 1.19, Linux to 5.15.58
See https://go.dev/doc/go1.19

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
2022-08-03 17:03:58 +04:00

82 lines
1.8 KiB
Go

// Code generated by "enumer -type=Port -text"; DO NOT EDIT.
package nethelpers
import (
"fmt"
)
const (
_PortName_0 = "TwistedPairAUIMIIFibreBNCDirectAttach"
_PortName_1 = "None"
_PortName_2 = "Other"
)
var (
_PortIndex_0 = [...]uint8{0, 11, 14, 17, 22, 25, 37}
_PortIndex_1 = [...]uint8{0, 4}
_PortIndex_2 = [...]uint8{0, 5}
)
func (i Port) String() string {
switch {
case 0 <= i && i <= 5:
return _PortName_0[_PortIndex_0[i]:_PortIndex_0[i+1]]
case i == 239:
return _PortName_1
case i == 255:
return _PortName_2
default:
return fmt.Sprintf("Port(%d)", i)
}
}
var _PortValues = []Port{0, 1, 2, 3, 4, 5, 239, 255}
var _PortNameToValueMap = map[string]Port{
_PortName_0[0:11]: 0,
_PortName_0[11:14]: 1,
_PortName_0[14:17]: 2,
_PortName_0[17:22]: 3,
_PortName_0[22:25]: 4,
_PortName_0[25:37]: 5,
_PortName_1[0:4]: 239,
_PortName_2[0:5]: 255,
}
// PortString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func PortString(s string) (Port, error) {
if val, ok := _PortNameToValueMap[s]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Port values", s)
}
// PortValues returns all values of the enum
func PortValues() []Port {
return _PortValues
}
// IsAPort returns "true" if the value is listed in the enum definition. "false" otherwise
func (i Port) IsAPort() bool {
for _, v := range _PortValues {
if i == v {
return true
}
}
return false
}
// MarshalText implements the encoding.TextMarshaler interface for Port
func (i Port) MarshalText() ([]byte, error) {
return []byte(i.String()), nil
}
// UnmarshalText implements the encoding.TextUnmarshaler interface for Port
func (i *Port) UnmarshalText(text []byte) error {
var err error
*i, err = PortString(string(text))
return err
}