github.com/bluenviron/gomavlib/v2@v2.2.1-0.20240308101627-2c07e3da629c/pkg/dialects/ardupilotmega/enum_gopro_field_of_view.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_FIELD_OF_VIEW uint64 11 12 const ( 13 // 0x00: Wide. 14 GOPRO_FIELD_OF_VIEW_WIDE GOPRO_FIELD_OF_VIEW = 0 15 // 0x01: Medium. 16 GOPRO_FIELD_OF_VIEW_MEDIUM GOPRO_FIELD_OF_VIEW = 1 17 // 0x02: Narrow. 18 GOPRO_FIELD_OF_VIEW_NARROW GOPRO_FIELD_OF_VIEW = 2 19 ) 20 21 var labels_GOPRO_FIELD_OF_VIEW = map[GOPRO_FIELD_OF_VIEW]string{ 22 GOPRO_FIELD_OF_VIEW_WIDE: "GOPRO_FIELD_OF_VIEW_WIDE", 23 GOPRO_FIELD_OF_VIEW_MEDIUM: "GOPRO_FIELD_OF_VIEW_MEDIUM", 24 GOPRO_FIELD_OF_VIEW_NARROW: "GOPRO_FIELD_OF_VIEW_NARROW", 25 } 26 27 var values_GOPRO_FIELD_OF_VIEW = map[string]GOPRO_FIELD_OF_VIEW{ 28 "GOPRO_FIELD_OF_VIEW_WIDE": GOPRO_FIELD_OF_VIEW_WIDE, 29 "GOPRO_FIELD_OF_VIEW_MEDIUM": GOPRO_FIELD_OF_VIEW_MEDIUM, 30 "GOPRO_FIELD_OF_VIEW_NARROW": GOPRO_FIELD_OF_VIEW_NARROW, 31 } 32 33 // MarshalText implements the encoding.TextMarshaler interface. 34 func (e GOPRO_FIELD_OF_VIEW) MarshalText() ([]byte, error) { 35 if name, ok := labels_GOPRO_FIELD_OF_VIEW[e]; ok { 36 return []byte(name), nil 37 } 38 return []byte(strconv.Itoa(int(e))), nil 39 } 40 41 // UnmarshalText implements the encoding.TextUnmarshaler interface. 42 func (e *GOPRO_FIELD_OF_VIEW) UnmarshalText(text []byte) error { 43 if value, ok := values_GOPRO_FIELD_OF_VIEW[string(text)]; ok { 44 *e = value 45 } else if value, err := strconv.Atoi(string(text)); err == nil { 46 *e = GOPRO_FIELD_OF_VIEW(value) 47 } else { 48 return fmt.Errorf("invalid label '%s'", text) 49 } 50 return nil 51 } 52 53 // String implements the fmt.Stringer interface. 54 func (e GOPRO_FIELD_OF_VIEW) String() string { 55 val, _ := e.MarshalText() 56 return string(val) 57 }