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

import (
	"fmt"
	"strconv"
)

type GOPRO_FIELD_OF_VIEW uint64

const (
	// 0x00: Wide.
	GOPRO_FIELD_OF_VIEW_WIDE GOPRO_FIELD_OF_VIEW = 0
	// 0x01: Medium.
	GOPRO_FIELD_OF_VIEW_MEDIUM GOPRO_FIELD_OF_VIEW = 1
	// 0x02: Narrow.
	GOPRO_FIELD_OF_VIEW_NARROW GOPRO_FIELD_OF_VIEW = 2
)

var value_to_label_GOPRO_FIELD_OF_VIEW = map[GOPRO_FIELD_OF_VIEW]string{
	GOPRO_FIELD_OF_VIEW_WIDE:   "GOPRO_FIELD_OF_VIEW_WIDE",
	GOPRO_FIELD_OF_VIEW_MEDIUM: "GOPRO_FIELD_OF_VIEW_MEDIUM",
	GOPRO_FIELD_OF_VIEW_NARROW: "GOPRO_FIELD_OF_VIEW_NARROW",
}

var label_to_value_GOPRO_FIELD_OF_VIEW = map[string]GOPRO_FIELD_OF_VIEW{
	"GOPRO_FIELD_OF_VIEW_WIDE":   GOPRO_FIELD_OF_VIEW_WIDE,
	"GOPRO_FIELD_OF_VIEW_MEDIUM": GOPRO_FIELD_OF_VIEW_MEDIUM,
	"GOPRO_FIELD_OF_VIEW_NARROW": GOPRO_FIELD_OF_VIEW_NARROW,
}

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

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

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