github.com/machinefi/w3bstream@v1.6.5-rc9.0.20240426031326-b8c7c4876e72/pkg/enums/wasm_db_dialect__generated.go (about) 1 // This is a generated source file. DO NOT EDIT 2 // Source: enums/wasm_db_dialect__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 InvalidWasmDBDialect = errors.New("invalid WasmDBDialect type") 15 16 func ParseWasmDBDialectFromString(s string) (WasmDBDialect, error) { 17 switch s { 18 default: 19 return WASM_DB_DIALECT_UNKNOWN, InvalidWasmDBDialect 20 case "": 21 return WASM_DB_DIALECT_UNKNOWN, nil 22 case "POSTGRES": 23 return WASM_DB_DIALECT__POSTGRES, nil 24 } 25 } 26 27 func ParseWasmDBDialectFromLabel(s string) (WasmDBDialect, error) { 28 switch s { 29 default: 30 return WASM_DB_DIALECT_UNKNOWN, InvalidWasmDBDialect 31 case "": 32 return WASM_DB_DIALECT_UNKNOWN, nil 33 case "POSTGRES": 34 return WASM_DB_DIALECT__POSTGRES, nil 35 } 36 } 37 38 func (v WasmDBDialect) Int() int { 39 return int(v) 40 } 41 42 func (v WasmDBDialect) String() string { 43 switch v { 44 default: 45 return "UNKNOWN" 46 case WASM_DB_DIALECT_UNKNOWN: 47 return "" 48 case WASM_DB_DIALECT__POSTGRES: 49 return "POSTGRES" 50 } 51 } 52 53 func (v WasmDBDialect) Label() string { 54 switch v { 55 default: 56 return "UNKNOWN" 57 case WASM_DB_DIALECT_UNKNOWN: 58 return "" 59 case WASM_DB_DIALECT__POSTGRES: 60 return "POSTGRES" 61 } 62 } 63 64 func (v WasmDBDialect) TypeName() string { 65 return "github.com/machinefi/w3bstream/pkg/enums.WasmDBDialect" 66 } 67 68 func (v WasmDBDialect) ConstValues() []enum.IntStringerEnum { 69 return []enum.IntStringerEnum{WASM_DB_DIALECT__POSTGRES} 70 } 71 72 func (v WasmDBDialect) MarshalText() ([]byte, error) { 73 s := v.String() 74 if s == "UNKNOWN" { 75 return nil, InvalidWasmDBDialect 76 } 77 return []byte(s), nil 78 } 79 80 func (v *WasmDBDialect) UnmarshalText(data []byte) error { 81 s := string(bytes.ToUpper(data)) 82 val, err := ParseWasmDBDialectFromString(s) 83 if err != nil { 84 return err 85 } 86 *(v) = val 87 return nil 88 } 89 90 func (v *WasmDBDialect) Scan(src interface{}) error { 91 offset := 0 92 o, ok := interface{}(v).(enum.ValueOffset) 93 if ok { 94 offset = o.Offset() 95 } 96 i, err := enum.ScanIntEnumStringer(src, offset) 97 if err != nil { 98 return err 99 } 100 *(v) = WasmDBDialect(i) 101 return nil 102 } 103 104 func (v WasmDBDialect) Value() (driver.Value, error) { 105 offset := 0 106 o, ok := interface{}(v).(enum.ValueOffset) 107 if ok { 108 offset = o.Offset() 109 } 110 return int64(v) + int64(offset), nil 111 }