//autogenerated:yes
//nolint:revive,misspell,govet,lll,dupl,gocritic
package uavionix

import (
	"fmt"
	"strconv"
)

// Emergency status encoding
type UAVIONIX_ADSB_EMERGENCY_STATUS uint64

const (
	UAVIONIX_ADSB_OUT_NO_EMERGENCY                    UAVIONIX_ADSB_EMERGENCY_STATUS = 0
	UAVIONIX_ADSB_OUT_GENERAL_EMERGENCY               UAVIONIX_ADSB_EMERGENCY_STATUS = 1
	UAVIONIX_ADSB_OUT_LIFEGUARD_EMERGENCY             UAVIONIX_ADSB_EMERGENCY_STATUS = 2
	UAVIONIX_ADSB_OUT_MINIMUM_FUEL_EMERGENCY          UAVIONIX_ADSB_EMERGENCY_STATUS = 3
	UAVIONIX_ADSB_OUT_NO_COMM_EMERGENCY               UAVIONIX_ADSB_EMERGENCY_STATUS = 4
	UAVIONIX_ADSB_OUT_UNLAWFUL_INTERFERANCE_EMERGENCY UAVIONIX_ADSB_EMERGENCY_STATUS = 5
	UAVIONIX_ADSB_OUT_DOWNED_AIRCRAFT_EMERGENCY       UAVIONIX_ADSB_EMERGENCY_STATUS = 6
	UAVIONIX_ADSB_OUT_RESERVED                        UAVIONIX_ADSB_EMERGENCY_STATUS = 7
)

var value_to_label_UAVIONIX_ADSB_EMERGENCY_STATUS = map[UAVIONIX_ADSB_EMERGENCY_STATUS]string{
	UAVIONIX_ADSB_OUT_NO_EMERGENCY:                    "UAVIONIX_ADSB_OUT_NO_EMERGENCY",
	UAVIONIX_ADSB_OUT_GENERAL_EMERGENCY:               "UAVIONIX_ADSB_OUT_GENERAL_EMERGENCY",
	UAVIONIX_ADSB_OUT_LIFEGUARD_EMERGENCY:             "UAVIONIX_ADSB_OUT_LIFEGUARD_EMERGENCY",
	UAVIONIX_ADSB_OUT_MINIMUM_FUEL_EMERGENCY:          "UAVIONIX_ADSB_OUT_MINIMUM_FUEL_EMERGENCY",
	UAVIONIX_ADSB_OUT_NO_COMM_EMERGENCY:               "UAVIONIX_ADSB_OUT_NO_COMM_EMERGENCY",
	UAVIONIX_ADSB_OUT_UNLAWFUL_INTERFERANCE_EMERGENCY: "UAVIONIX_ADSB_OUT_UNLAWFUL_INTERFERANCE_EMERGENCY",
	UAVIONIX_ADSB_OUT_DOWNED_AIRCRAFT_EMERGENCY:       "UAVIONIX_ADSB_OUT_DOWNED_AIRCRAFT_EMERGENCY",
	UAVIONIX_ADSB_OUT_RESERVED:                        "UAVIONIX_ADSB_OUT_RESERVED",
}

var label_to_value_UAVIONIX_ADSB_EMERGENCY_STATUS = map[string]UAVIONIX_ADSB_EMERGENCY_STATUS{
	"UAVIONIX_ADSB_OUT_NO_EMERGENCY":                    UAVIONIX_ADSB_OUT_NO_EMERGENCY,
	"UAVIONIX_ADSB_OUT_GENERAL_EMERGENCY":               UAVIONIX_ADSB_OUT_GENERAL_EMERGENCY,
	"UAVIONIX_ADSB_OUT_LIFEGUARD_EMERGENCY":             UAVIONIX_ADSB_OUT_LIFEGUARD_EMERGENCY,
	"UAVIONIX_ADSB_OUT_MINIMUM_FUEL_EMERGENCY":          UAVIONIX_ADSB_OUT_MINIMUM_FUEL_EMERGENCY,
	"UAVIONIX_ADSB_OUT_NO_COMM_EMERGENCY":               UAVIONIX_ADSB_OUT_NO_COMM_EMERGENCY,
	"UAVIONIX_ADSB_OUT_UNLAWFUL_INTERFERANCE_EMERGENCY": UAVIONIX_ADSB_OUT_UNLAWFUL_INTERFERANCE_EMERGENCY,
	"UAVIONIX_ADSB_OUT_DOWNED_AIRCRAFT_EMERGENCY":       UAVIONIX_ADSB_OUT_DOWNED_AIRCRAFT_EMERGENCY,
	"UAVIONIX_ADSB_OUT_RESERVED":                        UAVIONIX_ADSB_OUT_RESERVED,
}

// MarshalText implements the encoding.TextMarshaler interface.
func (e UAVIONIX_ADSB_EMERGENCY_STATUS) MarshalText() ([]byte, error) {
	if name, ok := value_to_label_UAVIONIX_ADSB_EMERGENCY_STATUS[e]; ok {
		return []byte(name), nil
	}
	return []byte(strconv.Itoa(int(e))), nil
}

// UnmarshalText implements the encoding.TextUnmarshaler interface.
func (e *UAVIONIX_ADSB_EMERGENCY_STATUS) UnmarshalText(text []byte) error {
	if value, ok := label_to_value_UAVIONIX_ADSB_EMERGENCY_STATUS[string(text)]; ok {
		*e = value
	} else if value, err := strconv.Atoi(string(text)); err == nil {
		*e = UAVIONIX_ADSB_EMERGENCY_STATUS(value)
	} else {
		return fmt.Errorf("invalid label '%s'", text)
	}
	return nil
}

// String implements the fmt.Stringer interface.
func (e UAVIONIX_ADSB_EMERGENCY_STATUS) String() string {
	val, _ := e.MarshalText()
	return string(val)
}
