// Code generated by "go-enum -type=TransportType"; DO NOT EDIT.

package enums

import (
	"database/sql"
	"database/sql/driver"
	"encoding"
	"encoding/json"
	"fmt"
	"strconv"
)

func _() {
	// An "invalid array index" compiler error signifies that the constant values have changed.
	// Re-run the stringer command to generate them again.
	var x [1]struct{}
	_ = x[NetHTTP-0]
	_ = x[FastHTTP-1]
}

const _TransportType_name = "NetHTTPFastHTTP"

var _TransportType_index = [...]uint8{0, 7, 15}

func _() {
	var _nil_TransportType_value = func() (val TransportType) { return }()

	// An "cannot convert TransportType literal (type TransportType) to type fmt.Stringer" compiler error signifies that the base type have changed.
	// Re-run the go-enum command to generate them again.
	var _ fmt.Stringer = _nil_TransportType_value
}

func (i TransportType) String() string {
	if i < 0 || i >= TransportType(len(_TransportType_index)-1) {
		return "TransportType(" + strconv.FormatInt(int64(i), 10) + ")"
	}
	return _TransportType_name[_TransportType_index[i]:_TransportType_index[i+1]]
}

// New returns a pointer to a new addr filled with the TransportType value passed in.
func (i TransportType) New() *TransportType {
	clone := i
	return &clone
}

var _TransportType_values = []TransportType{0, 1}

var _TransportType_name_to_values = map[string]TransportType{
	_TransportType_name[0:7]:  0,
	_TransportType_name[7:15]: 1,
}

// ParseTransportTypeString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func ParseTransportTypeString(s string) (TransportType, error) {
	if val, ok := _TransportType_name_to_values[s]; ok {
		return val, nil
	}
	return 0, fmt.Errorf("%s does not belong to TransportType values", s)
}

// TransportTypeValues returns all values of the enum
func TransportTypeValues() []TransportType {
	return _TransportType_values
}

// IsATransportType returns "true" if the value is listed in the enum definition. "false" otherwise
func (i TransportType) Registered() bool {
	for _, v := range _TransportType_values {
		if i == v {
			return true
		}
	}
	return false
}

func _() {
	var _nil_TransportType_value = func() (val TransportType) { return }()

	// An "cannot convert TransportType literal (type TransportType) to type encoding.BinaryMarshaler" compiler error signifies that the base type have changed.
	// Re-run the go-enum command to generate them again.
	var _ encoding.BinaryMarshaler = &_nil_TransportType_value

	// An "cannot convert TransportType literal (type TransportType) to type encoding.BinaryUnmarshaler" compiler error signifies that the base type have changed.
	// Re-run the go-enum command to generate them again.
	var _ encoding.BinaryUnmarshaler = &_nil_TransportType_value
}

// MarshalBinary implements the encoding.BinaryMarshaler interface for TransportType
func (i TransportType) MarshalBinary() (data []byte, err error) {
	return []byte(i.String()), nil
}

// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface for TransportType
func (i *TransportType) UnmarshalBinary(data []byte) error {
	var err error
	*i, err = ParseTransportTypeString(string(data))
	return err
}

func _() {
	var _nil_TransportType_value = func() (val TransportType) { return }()

	// An "cannot convert TransportType literal (type TransportType) to type json.Marshaler" compiler error signifies that the base type have changed.
	// Re-run the go-enum command to generate them again.
	var _ json.Marshaler = _nil_TransportType_value

	// An "cannot convert TransportType literal (type TransportType) to type encoding.Unmarshaler" compiler error signifies that the base type have changed.
	// Re-run the go-enum command to generate them again.
	var _ json.Unmarshaler = &_nil_TransportType_value
}

// MarshalJSON implements the json.Marshaler interface for TransportType
func (i TransportType) MarshalJSON() ([]byte, error) {
	return json.Marshal(i.String())
}

// UnmarshalJSON implements the json.Unmarshaler interface for TransportType
func (i *TransportType) UnmarshalJSON(data []byte) error {
	var s string
	if err := json.Unmarshal(data, &s); err != nil {
		return fmt.Errorf("TransportType should be a string, got %s", data)
	}

	var err error
	*i, err = ParseTransportTypeString(s)
	return err
}

func _() {
	var _nil_TransportType_value = func() (val TransportType) { return }()

	// An "cannot convert TransportType literal (type TransportType) to type encoding.TextMarshaler" compiler error signifies that the base type have changed.
	// Re-run the go-enum command to generate them again.
	var _ encoding.TextMarshaler = _nil_TransportType_value

	// An "cannot convert TransportType literal (type TransportType) to type encoding.TextUnmarshaler" compiler error signifies that the base type have changed.
	// Re-run the go-enum command to generate them again.
	var _ encoding.TextUnmarshaler = &_nil_TransportType_value
}

// MarshalText implements the encoding.TextMarshaler interface for TransportType
func (i TransportType) MarshalText() ([]byte, error) {
	return []byte(i.String()), nil
}

// UnmarshalText implements the encoding.TextUnmarshaler interface for TransportType
func (i *TransportType) UnmarshalText(text []byte) error {
	var err error
	*i, err = ParseTransportTypeString(string(text))
	return err
}

//func _() {
//	var _nil_TransportType_value = func() (val TransportType) { return }()
//
//	// An "cannot convert TransportType literal (type TransportType) to type yaml.Marshaler" compiler error signifies that the base type have changed.
//	// Re-run the go-enum command to generate them again.
//	var _ yaml.Marshaler = _nil_TransportType_value
//
//	// An "cannot convert TransportType literal (type TransportType) to type yaml.Unmarshaler" compiler error signifies that the base type have changed.
//	// Re-run the go-enum command to generate them again.
//	var _ yaml.Unmarshaler = &_nil_TransportType_value
//}

// MarshalYAML implements a YAML Marshaler for TransportType
func (i TransportType) MarshalYAML() (interface{}, error) {
	return i.String(), nil
}

// UnmarshalYAML implements a YAML Unmarshaler for TransportType
func (i *TransportType) UnmarshalYAML(unmarshal func(interface{}) error) error {
	var s string
	if err := unmarshal(&s); err != nil {
		return err
	}

	var err error
	*i, err = ParseTransportTypeString(s)
	return err
}

func _() {
	var _nil_TransportType_value = func() (val TransportType) { return }()

	// An "cannot convert TransportType literal (type TransportType) to type driver.Valuer" compiler error signifies that the base type have changed.
	// Re-run the go-enum command to generate them again.
	var _ driver.Valuer = _nil_TransportType_value

	// An "cannot convert TransportType literal (type TransportType) to type sql.Scanner" compiler error signifies that the base type have changed.
	// Re-run the go-enum command to generate them again.
	var _ sql.Scanner = &_nil_TransportType_value
}

func (i TransportType) Value() (driver.Value, error) {
	return i.String(), nil
}

func (i *TransportType) Scan(value interface{}) error {
	if value == nil {
		return nil
	}

	str, ok := value.(string)
	if !ok {
		bytes, ok := value.([]byte)
		if !ok {
			return fmt.Errorf("value is not a byte slice")
		}

		str = string(bytes[:])
	}

	val, err := ParseTransportTypeString(str)
	if err != nil {
		return err
	}

	*i = val
	return nil
}

// TransportTypeSliceContains reports whether sunEnums is within enums.
func TransportTypeSliceContains(enums []TransportType, sunEnums ...TransportType) bool {
	var seenEnums = map[TransportType]bool{}
	for _, e := range sunEnums {
		seenEnums[e] = false
	}

	for _, v := range enums {
		if _, has := seenEnums[v]; has {
			seenEnums[v] = true
		}
	}

	for _, seen := range seenEnums {
		if !seen {
			return false
		}
	}

	return true
}

// TransportTypeSliceContainsAny reports whether any sunEnum is within enums.
func TransportTypeSliceContainsAny(enums []TransportType, sunEnums ...TransportType) bool {
	var seenEnums = map[TransportType]struct{}{}
	for _, e := range sunEnums {
		seenEnums[e] = struct{}{}
	}

	for _, v := range enums {
		if _, has := seenEnums[v]; has {
			return true
		}
	}

	return false
}
