github.com/jshiv/can-go@v0.2.1-0.20210224011015-069e90e90bdf/pkg/descriptor/sendtype.go (about) 1 package descriptor 2 3 import "strings" 4 5 // SendType represents the send type of a message. 6 type SendType uint8 7 8 //go:generate stringer -type SendType -trimprefix SendType 9 10 const ( 11 // SendTypeNone means the send type is unknown or not specified. 12 SendTypeNone SendType = iota 13 // SendTypeCyclic means the message is sent cyclically. 14 SendTypeCyclic 15 // SendTypeEvent means the message is only sent upon event or request. 16 SendTypeEvent 17 ) 18 19 // UnmarshalString sets the value of *s from the provided string. 20 func (s *SendType) UnmarshalString(str string) error { 21 // TODO: Decide on conventions and make this more strict 22 switch strings.ToLower(str) { 23 case "cyclic", "cyclicifactive", "periodic", "fixedperiodic", "enabledperiodic", "eventperiodic": 24 *s = SendTypeCyclic 25 case "event", "onevent": 26 *s = SendTypeEvent 27 default: 28 *s = SendTypeNone 29 } 30 return nil 31 }