-
Notifications
You must be signed in to change notification settings - Fork 11
/
staking_log_type_enum.go
136 lines (117 loc) 路 3.67 KB
/
staking_log_type_enum.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
// Code generated by go-enum DO NOT EDIT.
// Version: 0.5.7
// Revision: bf63e108589bbd2327b13ec2c5da532aad234029
// Build Date: 2023-07-25T23:27:55Z
// Built By: goreleaser
package types
import (
"database/sql/driver"
"errors"
"fmt"
"strings"
)
const (
// StakingLogTypeDelegation is a StakingLogType of type delegation.
StakingLogTypeDelegation StakingLogType = "delegation"
// StakingLogTypeUnbonding is a StakingLogType of type unbonding.
StakingLogTypeUnbonding StakingLogType = "unbonding"
// StakingLogTypeRewards is a StakingLogType of type rewards.
StakingLogTypeRewards StakingLogType = "rewards"
// StakingLogTypeCommissions is a StakingLogType of type commissions.
StakingLogTypeCommissions StakingLogType = "commissions"
)
var ErrInvalidStakingLogType = fmt.Errorf("not a valid StakingLogType, try [%s]", strings.Join(_StakingLogTypeNames, ", "))
var _StakingLogTypeNames = []string{
string(StakingLogTypeDelegation),
string(StakingLogTypeUnbonding),
string(StakingLogTypeRewards),
string(StakingLogTypeCommissions),
}
// StakingLogTypeNames returns a list of possible string values of StakingLogType.
func StakingLogTypeNames() []string {
tmp := make([]string, len(_StakingLogTypeNames))
copy(tmp, _StakingLogTypeNames)
return tmp
}
// StakingLogTypeValues returns a list of the values for StakingLogType
func StakingLogTypeValues() []StakingLogType {
return []StakingLogType{
StakingLogTypeDelegation,
StakingLogTypeUnbonding,
StakingLogTypeRewards,
StakingLogTypeCommissions,
}
}
// String implements the Stringer interface.
func (x StakingLogType) String() string {
return string(x)
}
// IsValid provides a quick way to determine if the typed value is
// part of the allowed enumerated values
func (x StakingLogType) IsValid() bool {
_, err := ParseStakingLogType(string(x))
return err == nil
}
var _StakingLogTypeValue = map[string]StakingLogType{
"delegation": StakingLogTypeDelegation,
"unbonding": StakingLogTypeUnbonding,
"rewards": StakingLogTypeRewards,
"commissions": StakingLogTypeCommissions,
}
// ParseStakingLogType attempts to convert a string to a StakingLogType.
func ParseStakingLogType(name string) (StakingLogType, error) {
if x, ok := _StakingLogTypeValue[name]; ok {
return x, nil
}
return StakingLogType(""), fmt.Errorf("%s is %w", name, ErrInvalidStakingLogType)
}
// MarshalText implements the text marshaller method.
func (x StakingLogType) MarshalText() ([]byte, error) {
return []byte(string(x)), nil
}
// UnmarshalText implements the text unmarshaller method.
func (x *StakingLogType) UnmarshalText(text []byte) error {
tmp, err := ParseStakingLogType(string(text))
if err != nil {
return err
}
*x = tmp
return nil
}
var errStakingLogTypeNilPtr = errors.New("value pointer is nil") // one per type for package clashes
// Scan implements the Scanner interface.
func (x *StakingLogType) Scan(value interface{}) (err error) {
if value == nil {
*x = StakingLogType("")
return
}
// A wider range of scannable types.
// driver.Value values at the top of the list for expediency
switch v := value.(type) {
case string:
*x, err = ParseStakingLogType(v)
case []byte:
*x, err = ParseStakingLogType(string(v))
case StakingLogType:
*x = v
case *StakingLogType:
if v == nil {
return errStakingLogTypeNilPtr
}
*x = *v
case *string:
if v == nil {
return errStakingLogTypeNilPtr
}
*x, err = ParseStakingLogType(*v)
default:
return errors.New("invalid type for StakingLogType")
}
return
}
// Value implements the driver Valuer interface.
func (x StakingLogType) Value() (driver.Value, error) {
return x.String(), nil
}