github.com/bluenviron/gomavlib/v2@v2.2.1-0.20240308101627-2c07e3da629c/pkg/dialects/common/enum_storage_usage_flag.go (about) 1 //autogenerated:yes 2 //nolint:revive,misspell,govet,lll,dupl,gocritic 3 package common 4 5 import ( 6 "fmt" 7 "strconv" 8 ) 9 10 // Flags to indicate usage for a particular storage (see STORAGE_INFORMATION.storage_usage and MAV_CMD_SET_STORAGE_USAGE). 11 type STORAGE_USAGE_FLAG uint64 12 13 const ( 14 // Always set to 1 (indicates STORAGE_INFORMATION.storage_usage is supported). 15 STORAGE_USAGE_FLAG_SET STORAGE_USAGE_FLAG = 1 16 // Storage for saving photos. 17 STORAGE_USAGE_FLAG_PHOTO STORAGE_USAGE_FLAG = 2 18 // Storage for saving videos. 19 STORAGE_USAGE_FLAG_VIDEO STORAGE_USAGE_FLAG = 4 20 // Storage for saving logs. 21 STORAGE_USAGE_FLAG_LOGS STORAGE_USAGE_FLAG = 8 22 ) 23 24 var labels_STORAGE_USAGE_FLAG = map[STORAGE_USAGE_FLAG]string{ 25 STORAGE_USAGE_FLAG_SET: "STORAGE_USAGE_FLAG_SET", 26 STORAGE_USAGE_FLAG_PHOTO: "STORAGE_USAGE_FLAG_PHOTO", 27 STORAGE_USAGE_FLAG_VIDEO: "STORAGE_USAGE_FLAG_VIDEO", 28 STORAGE_USAGE_FLAG_LOGS: "STORAGE_USAGE_FLAG_LOGS", 29 } 30 31 var values_STORAGE_USAGE_FLAG = map[string]STORAGE_USAGE_FLAG{ 32 "STORAGE_USAGE_FLAG_SET": STORAGE_USAGE_FLAG_SET, 33 "STORAGE_USAGE_FLAG_PHOTO": STORAGE_USAGE_FLAG_PHOTO, 34 "STORAGE_USAGE_FLAG_VIDEO": STORAGE_USAGE_FLAG_VIDEO, 35 "STORAGE_USAGE_FLAG_LOGS": STORAGE_USAGE_FLAG_LOGS, 36 } 37 38 // MarshalText implements the encoding.TextMarshaler interface. 39 func (e STORAGE_USAGE_FLAG) MarshalText() ([]byte, error) { 40 if name, ok := labels_STORAGE_USAGE_FLAG[e]; ok { 41 return []byte(name), nil 42 } 43 return []byte(strconv.Itoa(int(e))), nil 44 } 45 46 // UnmarshalText implements the encoding.TextUnmarshaler interface. 47 func (e *STORAGE_USAGE_FLAG) UnmarshalText(text []byte) error { 48 if value, ok := values_STORAGE_USAGE_FLAG[string(text)]; ok { 49 *e = value 50 } else if value, err := strconv.Atoi(string(text)); err == nil { 51 *e = STORAGE_USAGE_FLAG(value) 52 } else { 53 return fmt.Errorf("invalid label '%s'", text) 54 } 55 return nil 56 } 57 58 // String implements the fmt.Stringer interface. 59 func (e STORAGE_USAGE_FLAG) String() string { 60 val, _ := e.MarshalText() 61 return string(val) 62 }