github.com/bluenviron/gomavlib/v2@v2.2.1-0.20240308101627-2c07e3da629c/pkg/dialects/ardupilotmega/enum_gopro_protune_colour.go (about)

     1  //autogenerated:yes
     2  //nolint:revive,misspell,govet,lll,dupl,gocritic
     3  package ardupilotmega
     4  
     5  import (
     6  	"fmt"
     7  	"strconv"
     8  )
     9  
    10  type GOPRO_PROTUNE_COLOUR uint64
    11  
    12  const (
    13  	// Auto.
    14  	GOPRO_PROTUNE_COLOUR_STANDARD GOPRO_PROTUNE_COLOUR = 0
    15  	// Neutral.
    16  	GOPRO_PROTUNE_COLOUR_NEUTRAL GOPRO_PROTUNE_COLOUR = 1
    17  )
    18  
    19  var labels_GOPRO_PROTUNE_COLOUR = map[GOPRO_PROTUNE_COLOUR]string{
    20  	GOPRO_PROTUNE_COLOUR_STANDARD: "GOPRO_PROTUNE_COLOUR_STANDARD",
    21  	GOPRO_PROTUNE_COLOUR_NEUTRAL:  "GOPRO_PROTUNE_COLOUR_NEUTRAL",
    22  }
    23  
    24  var values_GOPRO_PROTUNE_COLOUR = map[string]GOPRO_PROTUNE_COLOUR{
    25  	"GOPRO_PROTUNE_COLOUR_STANDARD": GOPRO_PROTUNE_COLOUR_STANDARD,
    26  	"GOPRO_PROTUNE_COLOUR_NEUTRAL":  GOPRO_PROTUNE_COLOUR_NEUTRAL,
    27  }
    28  
    29  // MarshalText implements the encoding.TextMarshaler interface.
    30  func (e GOPRO_PROTUNE_COLOUR) MarshalText() ([]byte, error) {
    31  	if name, ok := labels_GOPRO_PROTUNE_COLOUR[e]; ok {
    32  		return []byte(name), nil
    33  	}
    34  	return []byte(strconv.Itoa(int(e))), nil
    35  }
    36  
    37  // UnmarshalText implements the encoding.TextUnmarshaler interface.
    38  func (e *GOPRO_PROTUNE_COLOUR) UnmarshalText(text []byte) error {
    39  	if value, ok := values_GOPRO_PROTUNE_COLOUR[string(text)]; ok {
    40  		*e = value
    41  	} else if value, err := strconv.Atoi(string(text)); err == nil {
    42  		*e = GOPRO_PROTUNE_COLOUR(value)
    43  	} else {
    44  		return fmt.Errorf("invalid label '%s'", text)
    45  	}
    46  	return nil
    47  }
    48  
    49  // String implements the fmt.Stringer interface.
    50  func (e GOPRO_PROTUNE_COLOUR) String() string {
    51  	val, _ := e.MarshalText()
    52  	return string(val)
    53  }