github.com/machinefi/w3bstream@v1.6.5-rc9.0.20240426031326-b8c7c4876e72/pkg/enums/config_type__generated.go (about) 1 // This is a generated source file. DO NOT EDIT 2 // Source: enums/config_type__generated.go 3 4 package enums 5 6 import ( 7 "bytes" 8 "database/sql/driver" 9 "errors" 10 11 "github.com/machinefi/w3bstream/pkg/depends/kit/enum" 12 ) 13 14 var InvalidConfigType = errors.New("invalid ConfigType type") 15 16 func ParseConfigTypeFromString(s string) (ConfigType, error) { 17 switch s { 18 default: 19 return CONFIG_TYPE_UNKNOWN, InvalidConfigType 20 case "": 21 return CONFIG_TYPE_UNKNOWN, nil 22 case "PROJECT_DATABASE": 23 return CONFIG_TYPE__PROJECT_DATABASE, nil 24 case "INSTANCE_CACHE": 25 return CONFIG_TYPE__INSTANCE_CACHE, nil 26 case "PROJECT_ENV": 27 return CONFIG_TYPE__PROJECT_ENV, nil 28 case "PROJECT_FLOW": 29 return CONFIG_TYPE__PROJECT_FLOW, nil 30 } 31 } 32 33 func ParseConfigTypeFromLabel(s string) (ConfigType, error) { 34 switch s { 35 default: 36 return CONFIG_TYPE_UNKNOWN, InvalidConfigType 37 case "": 38 return CONFIG_TYPE_UNKNOWN, nil 39 case "PROJECT_DATABASE": 40 return CONFIG_TYPE__PROJECT_DATABASE, nil 41 case "INSTANCE_CACHE": 42 return CONFIG_TYPE__INSTANCE_CACHE, nil 43 case "PROJECT_ENV": 44 return CONFIG_TYPE__PROJECT_ENV, nil 45 case "PROJECT_FLOW": 46 return CONFIG_TYPE__PROJECT_FLOW, nil 47 } 48 } 49 50 func (v ConfigType) Int() int { 51 return int(v) 52 } 53 54 func (v ConfigType) String() string { 55 switch v { 56 default: 57 return "UNKNOWN" 58 case CONFIG_TYPE_UNKNOWN: 59 return "" 60 case CONFIG_TYPE__PROJECT_DATABASE: 61 return "PROJECT_DATABASE" 62 case CONFIG_TYPE__INSTANCE_CACHE: 63 return "INSTANCE_CACHE" 64 case CONFIG_TYPE__PROJECT_ENV: 65 return "PROJECT_ENV" 66 case CONFIG_TYPE__PROJECT_FLOW: 67 return "PROJECT_FLOW" 68 } 69 } 70 71 func (v ConfigType) Label() string { 72 switch v { 73 default: 74 return "UNKNOWN" 75 case CONFIG_TYPE_UNKNOWN: 76 return "" 77 case CONFIG_TYPE__PROJECT_DATABASE: 78 return "PROJECT_DATABASE" 79 case CONFIG_TYPE__INSTANCE_CACHE: 80 return "INSTANCE_CACHE" 81 case CONFIG_TYPE__PROJECT_ENV: 82 return "PROJECT_ENV" 83 case CONFIG_TYPE__PROJECT_FLOW: 84 return "PROJECT_FLOW" 85 } 86 } 87 88 func (v ConfigType) TypeName() string { 89 return "github.com/machinefi/w3bstream/pkg/enums.ConfigType" 90 } 91 92 func (v ConfigType) ConstValues() []enum.IntStringerEnum { 93 return []enum.IntStringerEnum{CONFIG_TYPE__PROJECT_DATABASE, CONFIG_TYPE__INSTANCE_CACHE, CONFIG_TYPE__PROJECT_ENV, CONFIG_TYPE__PROJECT_FLOW} 94 } 95 96 func (v ConfigType) MarshalText() ([]byte, error) { 97 s := v.String() 98 if s == "UNKNOWN" { 99 return nil, InvalidConfigType 100 } 101 return []byte(s), nil 102 } 103 104 func (v *ConfigType) UnmarshalText(data []byte) error { 105 s := string(bytes.ToUpper(data)) 106 val, err := ParseConfigTypeFromString(s) 107 if err != nil { 108 return err 109 } 110 *(v) = val 111 return nil 112 } 113 114 func (v *ConfigType) Scan(src interface{}) error { 115 offset := 0 116 o, ok := interface{}(v).(enum.ValueOffset) 117 if ok { 118 offset = o.Offset() 119 } 120 i, err := enum.ScanIntEnumStringer(src, offset) 121 if err != nil { 122 return err 123 } 124 *(v) = ConfigType(i) 125 return nil 126 } 127 128 func (v ConfigType) Value() (driver.Value, error) { 129 offset := 0 130 o, ok := interface{}(v).(enum.ValueOffset) 131 if ok { 132 offset = o.Offset() 133 } 134 return int64(v) + int64(offset), nil 135 }