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

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