github.com/bluenviron/gomavlib/v2@v2.2.1-0.20240308101627-2c07e3da629c/pkg/dialects/ardupilotmega/enum_mav_remote_log_data_block_statuses.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 // Possible remote log data block statuses. 11 type MAV_REMOTE_LOG_DATA_BLOCK_STATUSES uint64 12 13 const ( 14 // This block has NOT been received. 15 MAV_REMOTE_LOG_DATA_BLOCK_NACK MAV_REMOTE_LOG_DATA_BLOCK_STATUSES = 0 16 // This block has been received. 17 MAV_REMOTE_LOG_DATA_BLOCK_ACK MAV_REMOTE_LOG_DATA_BLOCK_STATUSES = 1 18 ) 19 20 var labels_MAV_REMOTE_LOG_DATA_BLOCK_STATUSES = map[MAV_REMOTE_LOG_DATA_BLOCK_STATUSES]string{ 21 MAV_REMOTE_LOG_DATA_BLOCK_NACK: "MAV_REMOTE_LOG_DATA_BLOCK_NACK", 22 MAV_REMOTE_LOG_DATA_BLOCK_ACK: "MAV_REMOTE_LOG_DATA_BLOCK_ACK", 23 } 24 25 var values_MAV_REMOTE_LOG_DATA_BLOCK_STATUSES = map[string]MAV_REMOTE_LOG_DATA_BLOCK_STATUSES{ 26 "MAV_REMOTE_LOG_DATA_BLOCK_NACK": MAV_REMOTE_LOG_DATA_BLOCK_NACK, 27 "MAV_REMOTE_LOG_DATA_BLOCK_ACK": MAV_REMOTE_LOG_DATA_BLOCK_ACK, 28 } 29 30 // MarshalText implements the encoding.TextMarshaler interface. 31 func (e MAV_REMOTE_LOG_DATA_BLOCK_STATUSES) MarshalText() ([]byte, error) { 32 if name, ok := labels_MAV_REMOTE_LOG_DATA_BLOCK_STATUSES[e]; ok { 33 return []byte(name), nil 34 } 35 return []byte(strconv.Itoa(int(e))), nil 36 } 37 38 // UnmarshalText implements the encoding.TextUnmarshaler interface. 39 func (e *MAV_REMOTE_LOG_DATA_BLOCK_STATUSES) UnmarshalText(text []byte) error { 40 if value, ok := values_MAV_REMOTE_LOG_DATA_BLOCK_STATUSES[string(text)]; ok { 41 *e = value 42 } else if value, err := strconv.Atoi(string(text)); err == nil { 43 *e = MAV_REMOTE_LOG_DATA_BLOCK_STATUSES(value) 44 } else { 45 return fmt.Errorf("invalid label '%s'", text) 46 } 47 return nil 48 } 49 50 // String implements the fmt.Stringer interface. 51 func (e MAV_REMOTE_LOG_DATA_BLOCK_STATUSES) String() string { 52 val, _ := e.MarshalText() 53 return string(val) 54 }