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

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