-
Notifications
You must be signed in to change notification settings - Fork 2
/
enum_permission.go
69 lines (56 loc) · 1.42 KB
/
enum_permission.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
// Code generated by "enumerator -type Permission -linecomment -trimprefix"; DO NOT EDIT.
package actor
import (
"fmt"
"strconv"
)
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[PermissionNone-0]
_ = x[PermissionAdmin-1]
}
const _Permission_name = "noneadmin"
var _Permission_index = [...]uint8{0, 4, 9}
func (i Permission) String() string {
if i >= Permission(len(_Permission_index)-1) {
return "Permission(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _Permission_name[_Permission_index[i]:_Permission_index[i+1]]
}
func (i Permission) MarshalText() ([]byte, error) {
return []byte(i.String()), nil
}
func (i *Permission) UnmarshalText(text []byte) error {
val, err := ParsePermission(string(text))
if err != nil {
return err
}
*i = val
return nil
}
func (i Permission) IsNone() bool {
return i == PermissionNone
}
func (i Permission) IsAdmin() bool {
return i == PermissionAdmin
}
func ParsePermission(s string) (Permission, error) {
switch s {
case "none":
return PermissionNone, nil
case "admin":
return PermissionAdmin, nil
default:
return Permission(0), fmt.Errorf("invalid Permission '%s'", s)
}
}
type PermissionOptions struct {
None Permission
Admin Permission
}
var PermissionValues = PermissionOptions{
None: PermissionNone,
Admin: PermissionAdmin,
}