github.com/machinefi/w3bstream@v1.6.5-rc9.0.20240426031326-b8c7c4876e72/pkg/enums/transaction_state__generated.go (about)

     1  // This is a generated source file. DO NOT EDIT
     2  // Source: enums/transaction_state__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 InvalidTransactionState = errors.New("invalid TransactionState type")
    15  
    16  func ParseTransactionStateFromString(s string) (TransactionState, error) {
    17  	switch s {
    18  	default:
    19  		return TRANSACTION_STATE_UNKNOWN, InvalidTransactionState
    20  	case "":
    21  		return TRANSACTION_STATE_UNKNOWN, nil
    22  	case "INIT":
    23  		return TRANSACTION_STATE__INIT, nil
    24  	case "PENDING":
    25  		return TRANSACTION_STATE__PENDING, nil
    26  	case "IN_BLOCK":
    27  		return TRANSACTION_STATE__IN_BLOCK, nil
    28  	case "CONFIRMED":
    29  		return TRANSACTION_STATE__CONFIRMED, nil
    30  	case "FAILED":
    31  		return TRANSACTION_STATE__FAILED, nil
    32  	}
    33  }
    34  
    35  func ParseTransactionStateFromLabel(s string) (TransactionState, error) {
    36  	switch s {
    37  	default:
    38  		return TRANSACTION_STATE_UNKNOWN, InvalidTransactionState
    39  	case "":
    40  		return TRANSACTION_STATE_UNKNOWN, nil
    41  	case "INIT":
    42  		return TRANSACTION_STATE__INIT, nil
    43  	case "PENDING":
    44  		return TRANSACTION_STATE__PENDING, nil
    45  	case "IN_BLOCK":
    46  		return TRANSACTION_STATE__IN_BLOCK, nil
    47  	case "CONFIRMED":
    48  		return TRANSACTION_STATE__CONFIRMED, nil
    49  	case "FAILED":
    50  		return TRANSACTION_STATE__FAILED, nil
    51  	}
    52  }
    53  
    54  func (v TransactionState) Int() int {
    55  	return int(v)
    56  }
    57  
    58  func (v TransactionState) String() string {
    59  	switch v {
    60  	default:
    61  		return "UNKNOWN"
    62  	case TRANSACTION_STATE_UNKNOWN:
    63  		return ""
    64  	case TRANSACTION_STATE__INIT:
    65  		return "INIT"
    66  	case TRANSACTION_STATE__PENDING:
    67  		return "PENDING"
    68  	case TRANSACTION_STATE__IN_BLOCK:
    69  		return "IN_BLOCK"
    70  	case TRANSACTION_STATE__CONFIRMED:
    71  		return "CONFIRMED"
    72  	case TRANSACTION_STATE__FAILED:
    73  		return "FAILED"
    74  	}
    75  }
    76  
    77  func (v TransactionState) Label() string {
    78  	switch v {
    79  	default:
    80  		return "UNKNOWN"
    81  	case TRANSACTION_STATE_UNKNOWN:
    82  		return ""
    83  	case TRANSACTION_STATE__INIT:
    84  		return "INIT"
    85  	case TRANSACTION_STATE__PENDING:
    86  		return "PENDING"
    87  	case TRANSACTION_STATE__IN_BLOCK:
    88  		return "IN_BLOCK"
    89  	case TRANSACTION_STATE__CONFIRMED:
    90  		return "CONFIRMED"
    91  	case TRANSACTION_STATE__FAILED:
    92  		return "FAILED"
    93  	}
    94  }
    95  
    96  func (v TransactionState) TypeName() string {
    97  	return "github.com/machinefi/w3bstream/pkg/enums.TransactionState"
    98  }
    99  
   100  func (v TransactionState) ConstValues() []enum.IntStringerEnum {
   101  	return []enum.IntStringerEnum{TRANSACTION_STATE__INIT, TRANSACTION_STATE__PENDING, TRANSACTION_STATE__IN_BLOCK, TRANSACTION_STATE__CONFIRMED, TRANSACTION_STATE__FAILED}
   102  }
   103  
   104  func (v TransactionState) MarshalText() ([]byte, error) {
   105  	s := v.String()
   106  	if s == "UNKNOWN" {
   107  		return nil, InvalidTransactionState
   108  	}
   109  	return []byte(s), nil
   110  }
   111  
   112  func (v *TransactionState) UnmarshalText(data []byte) error {
   113  	s := string(bytes.ToUpper(data))
   114  	val, err := ParseTransactionStateFromString(s)
   115  	if err != nil {
   116  		return err
   117  	}
   118  	*(v) = val
   119  	return nil
   120  }
   121  
   122  func (v *TransactionState) Scan(src interface{}) error {
   123  	offset := 0
   124  	o, ok := interface{}(v).(enum.ValueOffset)
   125  	if ok {
   126  		offset = o.Offset()
   127  	}
   128  	i, err := enum.ScanIntEnumStringer(src, offset)
   129  	if err != nil {
   130  		return err
   131  	}
   132  	*(v) = TransactionState(i)
   133  	return nil
   134  }
   135  
   136  func (v TransactionState) Value() (driver.Value, error) {
   137  	offset := 0
   138  	o, ok := interface{}(v).(enum.ValueOffset)
   139  	if ok {
   140  		offset = o.Offset()
   141  	}
   142  	return int64(v) + int64(offset), nil
   143  }