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

import (
	"fmt"
	"strconv"
)

// Source of information about this collision.
type MAV_COLLISION_SRC uint64

const (
	// ID field references ADSB_VEHICLE packets
	MAV_COLLISION_SRC_ADSB MAV_COLLISION_SRC = 0
	// ID field references MAVLink SRC ID
	MAV_COLLISION_SRC_MAVLINK_GPS_GLOBAL_INT MAV_COLLISION_SRC = 1
)

var value_to_label_MAV_COLLISION_SRC = map[MAV_COLLISION_SRC]string{
	MAV_COLLISION_SRC_ADSB:                   "MAV_COLLISION_SRC_ADSB",
	MAV_COLLISION_SRC_MAVLINK_GPS_GLOBAL_INT: "MAV_COLLISION_SRC_MAVLINK_GPS_GLOBAL_INT",
}

var label_to_value_MAV_COLLISION_SRC = map[string]MAV_COLLISION_SRC{
	"MAV_COLLISION_SRC_ADSB":                   MAV_COLLISION_SRC_ADSB,
	"MAV_COLLISION_SRC_MAVLINK_GPS_GLOBAL_INT": MAV_COLLISION_SRC_MAVLINK_GPS_GLOBAL_INT,
}

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

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

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