-
Notifications
You must be signed in to change notification settings - Fork 457
/
routingtable_enumer.go
74 lines (62 loc) · 1.88 KB
/
routingtable_enumer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Code generated by "enumer -type=RoutingTable -linecomment -text"; DO NOT EDIT.
package nethelpers
import (
"fmt"
)
const (
_RoutingTableName_0 = "unspec"
_RoutingTableName_1 = "defaultmainlocal"
)
var (
_RoutingTableIndex_0 = [...]uint8{0, 6}
_RoutingTableIndex_1 = [...]uint8{0, 7, 11, 16}
)
func (i RoutingTable) String() string {
switch {
case i == 0:
return _RoutingTableName_0
case 253 <= i && i <= 255:
i -= 253
return _RoutingTableName_1[_RoutingTableIndex_1[i]:_RoutingTableIndex_1[i+1]]
default:
return fmt.Sprintf("RoutingTable(%d)", i)
}
}
var _RoutingTableValues = []RoutingTable{0, 253, 254, 255}
var _RoutingTableNameToValueMap = map[string]RoutingTable{
_RoutingTableName_0[0:6]: 0,
_RoutingTableName_1[0:7]: 253,
_RoutingTableName_1[7:11]: 254,
_RoutingTableName_1[11:16]: 255,
}
// RoutingTableString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func RoutingTableString(s string) (RoutingTable, error) {
if val, ok := _RoutingTableNameToValueMap[s]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to RoutingTable values", s)
}
// RoutingTableValues returns all values of the enum
func RoutingTableValues() []RoutingTable {
return _RoutingTableValues
}
// IsARoutingTable returns "true" if the value is listed in the enum definition. "false" otherwise
func (i RoutingTable) IsARoutingTable() bool {
for _, v := range _RoutingTableValues {
if i == v {
return true
}
}
return false
}
// MarshalText implements the encoding.TextMarshaler interface for RoutingTable
func (i RoutingTable) MarshalText() ([]byte, error) {
return []byte(i.String()), nil
}
// UnmarshalText implements the encoding.TextUnmarshaler interface for RoutingTable
func (i *RoutingTable) UnmarshalText(text []byte) error {
var err error
*i, err = RoutingTableString(string(text))
return err
}