mirror of
https://github.com/bitmagnet-io/bitmagnet.git
synced 2026-07-20 11:15:17 -04:00
209 lines
4.9 KiB
Go
209 lines
4.9 KiB
Go
// Code generated by go-enum DO NOT EDIT.
|
|
// Version:
|
|
// Revision:
|
|
// Build Date:
|
|
// Built By:
|
|
|
|
package model
|
|
|
|
import (
|
|
"database/sql/driver"
|
|
"encoding/json"
|
|
"errors"
|
|
"fmt"
|
|
"io"
|
|
"strings"
|
|
)
|
|
|
|
const (
|
|
FilesStatusNoInfo FilesStatus = "no_info"
|
|
FilesStatusSingle FilesStatus = "single"
|
|
FilesStatusMulti FilesStatus = "multi"
|
|
FilesStatusOverThreshold FilesStatus = "over_threshold"
|
|
)
|
|
|
|
var ErrInvalidFilesStatus = fmt.Errorf("not a valid FilesStatus, try [%s]", strings.Join(_FilesStatusNames, ", "))
|
|
|
|
var _FilesStatusNames = []string{
|
|
string(FilesStatusNoInfo),
|
|
string(FilesStatusSingle),
|
|
string(FilesStatusMulti),
|
|
string(FilesStatusOverThreshold),
|
|
}
|
|
|
|
// FilesStatusNames returns a list of possible string values of FilesStatus.
|
|
func FilesStatusNames() []string {
|
|
tmp := make([]string, len(_FilesStatusNames))
|
|
copy(tmp, _FilesStatusNames)
|
|
return tmp
|
|
}
|
|
|
|
// FilesStatusValues returns a list of the values for FilesStatus
|
|
func FilesStatusValues() []FilesStatus {
|
|
return []FilesStatus{
|
|
FilesStatusNoInfo,
|
|
FilesStatusSingle,
|
|
FilesStatusMulti,
|
|
FilesStatusOverThreshold,
|
|
}
|
|
}
|
|
|
|
// String implements the Stringer interface.
|
|
func (x FilesStatus) 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 FilesStatus) IsValid() bool {
|
|
_, err := ParseFilesStatus(string(x))
|
|
return err == nil
|
|
}
|
|
|
|
var _FilesStatusValue = map[string]FilesStatus{
|
|
"no_info": FilesStatusNoInfo,
|
|
"single": FilesStatusSingle,
|
|
"multi": FilesStatusMulti,
|
|
"over_threshold": FilesStatusOverThreshold,
|
|
}
|
|
|
|
// ParseFilesStatus attempts to convert a string to a FilesStatus.
|
|
func ParseFilesStatus(name string) (FilesStatus, error) {
|
|
if x, ok := _FilesStatusValue[name]; ok {
|
|
return x, nil
|
|
}
|
|
// Case insensitive parse, do a separate lookup to prevent unnecessary cost of lowercasing a string if we don't need to.
|
|
if x, ok := _FilesStatusValue[strings.ToLower(name)]; ok {
|
|
return x, nil
|
|
}
|
|
return FilesStatus(""), fmt.Errorf("%s is %w", name, ErrInvalidFilesStatus)
|
|
}
|
|
|
|
// MarshalText implements the text marshaller method.
|
|
func (x FilesStatus) MarshalText() ([]byte, error) {
|
|
return []byte(string(x)), nil
|
|
}
|
|
|
|
// UnmarshalText implements the text unmarshaller method.
|
|
func (x *FilesStatus) UnmarshalText(text []byte) error {
|
|
tmp, err := ParseFilesStatus(string(text))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
*x = tmp
|
|
return nil
|
|
}
|
|
|
|
var errFilesStatusNilPtr = errors.New("value pointer is nil") // one per type for package clashes
|
|
|
|
// Scan implements the Scanner interface.
|
|
func (x *FilesStatus) Scan(value interface{}) (err error) {
|
|
if value == nil {
|
|
*x = FilesStatus("")
|
|
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 = ParseFilesStatus(v)
|
|
case []byte:
|
|
*x, err = ParseFilesStatus(string(v))
|
|
case FilesStatus:
|
|
*x = v
|
|
case *FilesStatus:
|
|
if v == nil {
|
|
return errFilesStatusNilPtr
|
|
}
|
|
*x = *v
|
|
case *string:
|
|
if v == nil {
|
|
return errFilesStatusNilPtr
|
|
}
|
|
*x, err = ParseFilesStatus(*v)
|
|
default:
|
|
return errors.New("invalid type for FilesStatus")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// Value implements the driver Valuer interface.
|
|
func (x FilesStatus) Value() (driver.Value, error) {
|
|
return x.String(), nil
|
|
}
|
|
|
|
type NullFilesStatus struct {
|
|
FilesStatus FilesStatus
|
|
Valid bool
|
|
Set bool
|
|
}
|
|
|
|
func NewNullFilesStatus(val interface{}) (x NullFilesStatus) {
|
|
err := x.Scan(val) // yes, we ignore this error, it will just be an invalid value.
|
|
_ = err // make any errcheck linters happy
|
|
return
|
|
}
|
|
|
|
// Scan implements the Scanner interface.
|
|
func (x *NullFilesStatus) Scan(value interface{}) (err error) {
|
|
if value == nil {
|
|
x.FilesStatus, x.Valid = FilesStatus(""), false
|
|
return
|
|
}
|
|
|
|
err = x.FilesStatus.Scan(value)
|
|
x.Valid = (err == nil)
|
|
return
|
|
}
|
|
|
|
// Value implements the driver Valuer interface.
|
|
func (x NullFilesStatus) Value() (driver.Value, error) {
|
|
if !x.Valid {
|
|
return nil, nil
|
|
}
|
|
return x.FilesStatus.String(), nil
|
|
}
|
|
|
|
// MarshalJSON correctly serializes a NullFilesStatus to JSON.
|
|
func (n NullFilesStatus) MarshalJSON() ([]byte, error) {
|
|
const nullStr = "null"
|
|
if n.Valid {
|
|
return json.Marshal(n.FilesStatus)
|
|
}
|
|
return []byte(nullStr), nil
|
|
}
|
|
|
|
// UnmarshalJSON correctly deserializes a NullFilesStatus from JSON.
|
|
func (n *NullFilesStatus) UnmarshalJSON(b []byte) error {
|
|
n.Set = true
|
|
var x interface{}
|
|
err := json.Unmarshal(b, &x)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
err = n.Scan(x)
|
|
return err
|
|
}
|
|
|
|
// MarshalGQL correctly serializes a NullFilesStatus to GraphQL.
|
|
func (n NullFilesStatus) MarshalGQL(w io.Writer) {
|
|
bytes, err := json.Marshal(n)
|
|
if err == nil {
|
|
_, _ = w.Write(bytes)
|
|
}
|
|
}
|
|
|
|
// UnmarshalGQL correctly deserializes a NullFilesStatus from GraphQL.
|
|
func (n *NullFilesStatus) UnmarshalGQL(v any) error {
|
|
if v == nil {
|
|
return nil
|
|
}
|
|
str, ok := v.(string)
|
|
if !ok {
|
|
return errors.New("value is not a string")
|
|
}
|
|
return n.UnmarshalJSON([]byte(str))
|
|
}
|