github.com/bluenviron/gomavlib/v2@v2.2.1-0.20240308101627-2c07e3da629c/pkg/dialects/ardupilotmega/enum_gopro_request_status.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_REQUEST_STATUS uint64 11 12 const ( 13 // The write message with ID indicated succeeded. 14 GOPRO_REQUEST_SUCCESS GOPRO_REQUEST_STATUS = 0 15 // The write message with ID indicated failed. 16 GOPRO_REQUEST_FAILED GOPRO_REQUEST_STATUS = 1 17 ) 18 19 var labels_GOPRO_REQUEST_STATUS = map[GOPRO_REQUEST_STATUS]string{ 20 GOPRO_REQUEST_SUCCESS: "GOPRO_REQUEST_SUCCESS", 21 GOPRO_REQUEST_FAILED: "GOPRO_REQUEST_FAILED", 22 } 23 24 var values_GOPRO_REQUEST_STATUS = map[string]GOPRO_REQUEST_STATUS{ 25 "GOPRO_REQUEST_SUCCESS": GOPRO_REQUEST_SUCCESS, 26 "GOPRO_REQUEST_FAILED": GOPRO_REQUEST_FAILED, 27 } 28 29 // MarshalText implements the encoding.TextMarshaler interface. 30 func (e GOPRO_REQUEST_STATUS) MarshalText() ([]byte, error) { 31 if name, ok := labels_GOPRO_REQUEST_STATUS[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_REQUEST_STATUS) UnmarshalText(text []byte) error { 39 if value, ok := values_GOPRO_REQUEST_STATUS[string(text)]; ok { 40 *e = value 41 } else if value, err := strconv.Atoi(string(text)); err == nil { 42 *e = GOPRO_REQUEST_STATUS(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_REQUEST_STATUS) String() string { 51 val, _ := e.MarshalText() 52 return string(val) 53 }