// Code generated by "enumer -type=Protocol -linecomment -text"; DO NOT EDIT. package nethelpers import ( "fmt" ) const ( _ProtocolName_0 = "tcp" _ProtocolName_1 = "udp" ) var ( _ProtocolIndex_0 = [...]uint8{0, 3} _ProtocolIndex_1 = [...]uint8{0, 3} ) func (i Protocol) String() string { switch { case i == 6: return _ProtocolName_0 case i == 17: return _ProtocolName_1 default: return fmt.Sprintf("Protocol(%d)", i) } } var _ProtocolValues = []Protocol{6, 17} var _ProtocolNameToValueMap = map[string]Protocol{ _ProtocolName_0[0:3]: 6, _ProtocolName_1[0:3]: 17, } // ProtocolString retrieves an enum value from the enum constants string name. // Throws an error if the param is not part of the enum. func ProtocolString(s string) (Protocol, error) { if val, ok := _ProtocolNameToValueMap[s]; ok { return val, nil } return 0, fmt.Errorf("%s does not belong to Protocol values", s) } // ProtocolValues returns all values of the enum func ProtocolValues() []Protocol { return _ProtocolValues } // IsAProtocol returns "true" if the value is listed in the enum definition. "false" otherwise func (i Protocol) IsAProtocol() bool { for _, v := range _ProtocolValues { if i == v { return true } } return false } // MarshalText implements the encoding.TextMarshaler interface for Protocol func (i Protocol) MarshalText() ([]byte, error) { return []byte(i.String()), nil } // UnmarshalText implements the encoding.TextUnmarshaler interface for Protocol func (i *Protocol) UnmarshalText(text []byte) error { var err error *i, err = ProtocolString(string(text)) return err }