package proto import "errors" type LuxType uint const ( LuxTypeHost = 0 LuxTypeNode = 1 ) const LUX_PROTO_TYPE_SIZE = 2 func LuxTypeFromString(name string) (LuxType, error) { switch name { case "host": return LuxTypeHost, nil case "node": return LuxTypeNode, nil default: return LuxTypeHost, errors.New("unknown lux type") } } func (luxType *LuxType) Read(rd *LuxBuffer) error { if val, err := rd.ReadUint16(); err != nil { return err } else { *luxType = LuxType(val) return nil } } func (luxType *LuxType) Write(wd *LuxBuffer) { wd.WriteUint16(uint16(*luxType)) } func (luxType *LuxType) String() string { switch *luxType { case LuxTypeHost: return "host" case LuxTypeNode: return "node" default: return "unknown" } }