// deserialize deserializes a custom websocket message from the client
// ex: iris-websocket-message;chat;4;themarshaledstringfromajsonstruct will return 'hello' as string
// Supported data types are: string, int, bool, bytes and JSON.
485701
func (ms *messageSerializer) deserialize(event []byte, websocketMessage []byte) (interface{}, error) {
	dataStartIdx := ms.prefixAndSepIdx + len(event) + 3
	if len(websocketMessage) <= dataStartIdx {
		return nil, errors.New("websocket invalid message: " + string(websocketMessage))
	}

	typ, err := strconv.Atoi(string(websocketMessage[ms.prefixAndSepIdx+len(event)+1 : ms.prefixAndSepIdx+len(event)+2])) // in order to iris-websocket-message;user;-> 4
	if err != nil {
		return nil, err
	}

	data := websocketMessage[dataStartIdx:] // in order to iris-websocket-message;user;4; -> themarshaledstringfromajsonstruct

	switch messageType(typ) {
	case messageTypeString:
		return string(data), nil
	case messageTypeInt:
		msg, err := strconv.Atoi(string(data))
		if err != nil {
			return nil, err
		}
		return msg, nil
	case messageTypeBool:
		if bytes.Equal(data, boolTrueB) {
			return true, nil
		}
		return false, nil
	case messageTypeBytes:
		return data, nil
	case messageTypeJSON:
		var msg interface{}
		err := json.Unmarshal(data, &msg)
		return msg, err
	default:
		return nil, errInvalidTypeMessage.Format(messageType(typ).Name(), websocketMessage)
	}
}
536792
func Deserialize(p []byte) (*load.LoadAvg, error) {
	var l load.LoadAvg
	err := json.Unmarshal(p, &l)
	if err != nil {
		return nil, err
	}
	return &l, nil
}
922743
func deserialize(token string) (*tokenserver.MachineTokenEnvelope, *tokenserver.MachineTokenBody, error) {
	tokenBinBlob, err := base64.RawStdEncoding.DecodeString(token)
	if err != nil {
		return nil, nil, err
	}
	envelope := &tokenserver.MachineTokenEnvelope{}
	if err := proto.Unmarshal(tokenBinBlob, envelope); err != nil {
		return nil, nil, err
	}
	body := &tokenserver.MachineTokenBody{}
	if err := proto.Unmarshal(envelope.TokenBody, body); err != nil {
		return envelope, nil, err
	}
	return envelope, body, nil
}
602177
func (e GobEncoder) Deserialize(src []byte, dst interface{}) error {
	dec := gob.NewDecoder(bytes.NewBuffer(src))
	if err := dec.Decode(dst); err != nil {
		return cookieError{cause: err, typ: decodeError}
	}
	return nil
}
324769
func Deserialize(p []byte) (*stats.CPUStats, error) {
	st := &stats.CPUStats{}
	err := json.Unmarshal(p, st)
	if err != nil {
		return nil, err
	}
	return st, nil
}
395560
func (j JSONStateSerializer) Serialize(state interface{}) (string, error) {
	var b bytes.Buffer
	if err := json.NewEncoder(&b).Encode(state); err != nil {
		return "", err
	}
	return b.String(), nil
}
1065183
func Deserialize(p []byte) (*numa.Nodes, error) {
	nodes := &numa.Nodes{}
	err := json.Unmarshal(p, nodes)
	if err != nil {
		return nil, err
	}
	return nodes, nil
}
1232053
func Deserialize(p []byte) (*x.CPUs, error) {
	cpus := &x.CPUs{}
	err := json.Unmarshal(p, cpus)
	if err != nil {
		return nil, err
	}
	return cpus, nil
}
706503
func Serialize(data interface{}) (bytes []byte, err error) {
	switch data.(type) {
	case []byte:
		return data.([]byte), nil
	case string:
		return []byte(data.(string)), nil
	default:
		if data != nil {
			return []byte(fmt.Sprint(data)), nil
		}
	}
	return nil, nil
}
1348956
func deserializeVLQ(serialized []byte) (uint64, int) {
	var n uint64
	var size int
	for _, val := range serialized {
		size++
		n = (n << 7) | uint64(val&0x7f)
		if val&0x80 != 0x80 {
			break
		}
		n++
	}

	return n, size
}
568133
func Deserialize(p []byte) (*structs.DevUsage, error) {
	u := &structs.DevUsage{}
	err := json.Unmarshal(p, u)
	if err != nil {
		return nil, err
	}
	return u, nil
}
336970
func (d *Decoder) Decode(v interface{}) (int, error) {
	if v == nil {
		msg := "can't unmarshal to nil interface"
		return 0, unmarshalError("Unmarshal", ErrNilInterface, msg, nil,
			nil)
	}

	vv := reflect.ValueOf(v)
	if vv.Kind() != reflect.Ptr {
		msg := fmt.Sprintf("can't unmarshal to non-pointer '%v' - use "+
			"& operator", vv.Type().String())
		err := unmarshalError("Unmarshal", ErrBadArguments, msg, nil, nil)
		return 0, err
	}
	if vv.IsNil() && !vv.CanSet() {
		msg := fmt.Sprintf("can't unmarshal to unsettable '%v' - use "+
			"& operator", vv.Type().String())
		err := unmarshalError("Unmarshal", ErrNotSettable, msg, nil, nil)
		return 0, err
	}

	return d.decode(vv)
}
673332
func Deserialize(p []byte) *freq.Frequency {
	ff := structs.GetRootAsFrequency(p, 0)
	l := ff.CPULength()
	f := &freq.Frequency{}
	fCPU := &structs.CPU{}
	cpu := freq.CPU{}
	f.Timestamp = ff.Timestamp()
	f.Sockets = ff.Sockets()
	for i := 0; i < l; i++ {
		if !ff.CPU(fCPU, i) {
			continue
		}
		cpu.Processor = fCPU.Processor()
		cpu.CPUMHz = fCPU.CPUMHz()
		cpu.PhysicalID = fCPU.PhysicalID()
		cpu.CoreID = fCPU.CoreID()
		cpu.APICID = fCPU.APICID()
		f.CPU = append(f.CPU, cpu)
	}
	return f
}
1112525
func (ra *responseAPDU) deserialize(data []byte) error {
	if len(data) < 2 {
		return fmt.Errorf("can not deserialize data: payload too short (%d < 2)", len(data))
	}

	ra.Data = make([]byte, len(data)-2)

	buf := bytes.NewReader(data)
	if err := binary.Read(buf, binary.BigEndian, &ra.Data); err != nil {
		return err
	}
	if err := binary.Read(buf, binary.BigEndian, &ra.Sw1); err != nil {
		return err
	}
	if err := binary.Read(buf, binary.BigEndian, &ra.Sw2); err != nil {
		return err
	}
	return nil
}
1328679
func Deserialize(p []byte) *o.OS {
	flatOS := structs.GetRootAsOS(p, 0)
	var os o.OS
	os.Name = string(flatOS.Name())
	os.ID = string(flatOS.ID())
	os.IDLike = string(flatOS.IDLike())
	os.HomeURL = string(flatOS.HomeURL())
	os.PrettyName = string(flatOS.PrettyName())
	os.Version = string(flatOS.Version())
	os.VersionID = string(flatOS.VersionID())
	os.BugReportURL = string(flatOS.BugReportURL())
	return &os
}
957163
func Deserialize(p []byte) (*structs.DevInfo, error) {
	info := &structs.DevInfo{}
	err := json.Unmarshal(p, info)
	if err != nil {
		return nil, err
	}
	return info, nil
}
1301223
func Deserialize(p []byte) *info.CPUInfo {
	fInf := structs.GetRootAsCPUInfo(p, 0)
	l := fInf.CPULength()
	inf := &info.CPUInfo{}
	fCPU := &structs.CPU{}
	cpu := info.CPU{}
	inf.Timestamp = fInf.Timestamp()
	inf.Sockets = fInf.Sockets()
	for i := 0; i < l; i++ {
		if !fInf.CPU(fCPU, i) {
			continue
		}
		cpu.Processor = fCPU.Processor()
		cpu.VendorID = string(fCPU.VendorID())
		cpu.CPUFamily = string(fCPU.CPUFamily())
		cpu.Model = string(fCPU.Model())
		cpu.ModelName = string(fCPU.ModelName())
		cpu.Stepping = string(fCPU.Stepping())
		cpu.Microcode = string(fCPU.Microcode())
		cpu.CPUMHz = fCPU.CPUMHz()
		cpu.CacheSize = string(fCPU.CacheSize())
		cpu.PhysicalID = fCPU.PhysicalID()
		cpu.Siblings = fCPU.Siblings()
		cpu.CoreID = fCPU.CoreID()
		cpu.CPUCores = fCPU.CPUCores()
		cpu.APICID = fCPU.APICID()
		cpu.InitialAPICID = fCPU.InitialAPICID()
		cpu.FPU = string(fCPU.FPU())
		cpu.FPUException = string(fCPU.FPUException())
		cpu.CPUIDLevel = string(fCPU.CPUIDLevel())
		cpu.WP = string(fCPU.WP())
		cpu.Flags = make([]string, fCPU.FlagsLength())
		for i := 0; i < len(cpu.Flags); i++ {
			cpu.Flags[i] = string(fCPU.Flags(i))
		}
		cpu.BogoMIPS = fCPU.BogoMIPS()
		cpu.CLFlushSize = fCPU.CLFlushSize()
		cpu.CacheAlignment = fCPU.CacheAlignment()
		cpu.AddressSizes = make([]string, fCPU.AddressSizesLength())
		for i := 0; i < len(cpu.AddressSizes); i++ {
			cpu.AddressSizes[i] = string(fCPU.AddressSizes(i))
		}
		cpu.PowerManagement = make([]string, fCPU.PowerManagementLength())
		for i := 0; i < len(cpu.PowerManagement); i++ {
			cpu.PowerManagement[i] = string(fCPU.PowerManagement(i))
		}
		cpu.TLBSize = string(fCPU.TLBSize())
		cpu.Bugs = make([]string, fCPU.BugsLength())
		for i := 0; i < len(cpu.Bugs); i++ {
			cpu.Bugs[i] = string(fCPU.Bugs(i))
		}
		inf.CPU = append(inf.CPU, cpu)
	}
	return inf
}