github.com/bluenviron/gomavlib/v2@v2.2.1-0.20240308101627-2c07e3da629c/pkg/dialects/common/enum_can_filter_op.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 type CAN_FILTER_OP uint64 11 12 const ( 13 CAN_FILTER_REPLACE CAN_FILTER_OP = 0 14 CAN_FILTER_ADD CAN_FILTER_OP = 1 15 CAN_FILTER_REMOVE CAN_FILTER_OP = 2 16 ) 17 18 var labels_CAN_FILTER_OP = map[CAN_FILTER_OP]string{ 19 CAN_FILTER_REPLACE: "CAN_FILTER_REPLACE", 20 CAN_FILTER_ADD: "CAN_FILTER_ADD", 21 CAN_FILTER_REMOVE: "CAN_FILTER_REMOVE", 22 } 23 24 var values_CAN_FILTER_OP = map[string]CAN_FILTER_OP{ 25 "CAN_FILTER_REPLACE": CAN_FILTER_REPLACE, 26 "CAN_FILTER_ADD": CAN_FILTER_ADD, 27 "CAN_FILTER_REMOVE": CAN_FILTER_REMOVE, 28 } 29 30 // MarshalText implements the encoding.TextMarshaler interface. 31 func (e CAN_FILTER_OP) MarshalText() ([]byte, error) { 32 if name, ok := labels_CAN_FILTER_OP[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 *CAN_FILTER_OP) UnmarshalText(text []byte) error { 40 if value, ok := values_CAN_FILTER_OP[string(text)]; ok { 41 *e = value 42 } else if value, err := strconv.Atoi(string(text)); err == nil { 43 *e = CAN_FILTER_OP(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 CAN_FILTER_OP) String() string { 52 val, _ := e.MarshalText() 53 return string(val) 54 }