// Serialize serializes cpux.CPUs using Flatbuffers.
972938
func (p *Profiler) Serialize(cpus *cpux.CPUs) []byte {
	// ensure the Builder is in a usable state.
	p.Builder.Reset()
	possible := p.Builder.CreateString(cpus.Possible)
	online := p.Builder.CreateString(cpus.Online)
	offline := p.Builder.CreateString(cpus.Offline)
	present := p.Builder.CreateString(cpus.Present)
	uoffs := make([]fb.UOffsetT, len(cpus.CPU))
	for i, cpu := range cpus.CPU {
		uoffs[i] = p.SerializeCPU(&cpu)
	}
	structs.CPUsStartCPUVector(p.Builder, len(uoffs))
	for i := len(uoffs) - 1; i >= 0; i-- {
		p.Builder.PrependUOffsetT(uoffs[i])
	}
	cpusV := p.Builder.EndVector(len(uoffs))
	structs.CPUsStart(p.Builder)
	structs.CPUsAddSockets(p.Builder, cpus.Sockets)
	structs.CPUsAddPossible(p.Builder, possible)
	structs.CPUsAddOnline(p.Builder, online)
	structs.CPUsAddOffline(p.Builder, offline)
	structs.CPUsAddPresent(p.Builder, present)
	structs.CPUsAddCPU(p.Builder, cpusV)
	p.Builder.Finish(structs.CPUsEnd(p.Builder))
	b := p.Builder.Bytes[p.Builder.Head():]
	// copy them (otherwise gets lost in reset)
	tmp := make([]byte, len(b))
	copy(tmp, b)
	return tmp
}
1115592
func Deserialize(p []byte) *cpux.CPUs {
	fcpus := structs.GetRootAsCPUs(p, 0)
	l := fcpus.CPULength()
	cpus := &cpux.CPUs{}
	fCPU := &structs.CPU{}
	fCache := &structs.CacheInf{}
	cpu := cpux.CPU{}
	cpus.Sockets = fcpus.Sockets()
	cpus.Possible = string(fcpus.Possible())
	cpus.Online = string(fcpus.Online())
	cpus.Present = string(fcpus.Present())
	for i := 0; i < l; i++ {
		if !fcpus.CPU(fCPU, i) {
			continue
		}
		cpu.PhysicalPackageID = fCPU.PhysicalPackageID()
		cpu.CoreID = fCPU.CoreID()
		cpu.MHzMin = fCPU.MHzMin()
		cpu.MHzMax = fCPU.MHzMax()
		caches := fCPU.CacheLength()
		cpu.CacheIDs = make([]string, 0, caches)
		cpu.Cache = make(map[string]string, caches)
		for j := 0; j < caches; j++ {
			if !fCPU.Cache(fCache, j) {
				continue
			}
			cpu.CacheIDs = append(cpu.CacheIDs, string(fCache.ID()))
			cpu.Cache[cpu.CacheIDs[j]] = string(fCache.Size())
		}
		cpus.CPU = append(cpus.CPU, cpu)
	}
	return cpus
}
237811
func Serialize(st *structs.DiskStats) (p []byte, err error) {
	stdMu.Lock()
	defer stdMu.Unlock()
	if std == nil {
		std, err = NewProfiler()
		if err != nil {
			return nil, err
		}
	}
	return std.Serialize(st)
}
730252
func (p *Profiler) Serialize(inf *info.CPUInfo) []byte {
	// ensure the Builder is in a usable state.
	p.Builder.Reset()
	uoffs := make([]fb.UOffsetT, len(inf.CPU))
	for i, cpu := range inf.CPU {
		uoffs[i] = p.SerializeCPU(&cpu)
	}
	structs.CPUInfoStartCPUVector(p.Builder, len(uoffs))
	for i := len(uoffs) - 1; i >= 0; i-- {
		p.Builder.PrependUOffsetT(uoffs[i])
	}
	cpusV := p.Builder.EndVector(len(uoffs))
	structs.CPUInfoStart(p.Builder)
	structs.CPUInfoAddTimestamp(p.Builder, inf.Timestamp)
	structs.CPUInfoAddSockets(p.Builder, inf.Sockets)
	structs.CPUInfoAddCPU(p.Builder, cpusV)
	p.Builder.Finish(structs.CPUInfoEnd(p.Builder))
	b := p.Builder.Bytes[p.Builder.Head():]
	// copy them (otherwise gets lost in reset)
	tmp := make([]byte, len(b))
	copy(tmp, b)
	return tmp
}
810801
func (p *PrivateKey) Serialize() []byte {
	b := make([]byte, 0, PrivKeyBytesLen)
	return paddedAppend(PrivKeyBytesLen, b, p.ToECDSA().D.Bytes())
}
640658
func (prof *Profiler) Serialize(u *structs.DiskUsage) []byte {
	// ensure the Builder is in a usable state.
	prof.Builder.Reset()
	devF := make([]fb.UOffsetT, len(u.Device))
	names := make([]fb.UOffsetT, len(u.Device))
	for i := 0; i < len(names); i++ {
		names[i] = prof.Builder.CreateString(u.Device[i].Name)
	}
	for i := 0; i < len(devF); i++ {
		flat.DeviceStart(prof.Builder)
		flat.DeviceAddMajor(prof.Builder, u.Device[i].Major)
		flat.DeviceAddMinor(prof.Builder, u.Device[i].Minor)
		flat.DeviceAddName(prof.Builder, names[i])
		flat.DeviceAddReadsCompleted(prof.Builder, u.Device[i].ReadsCompleted)
		flat.DeviceAddReadsMerged(prof.Builder, u.Device[i].ReadsMerged)
		flat.DeviceAddReadSectors(prof.Builder, u.Device[i].ReadSectors)
		flat.DeviceAddReadingTime(prof.Builder, u.Device[i].ReadingTime)
		flat.DeviceAddWritesCompleted(prof.Builder, u.Device[i].WritesCompleted)
		flat.DeviceAddWritesMerged(prof.Builder, u.Device[i].WritesMerged)
		flat.DeviceAddWrittenSectors(prof.Builder, u.Device[i].WrittenSectors)
		flat.DeviceAddWritingTime(prof.Builder, u.Device[i].WritingTime)
		flat.DeviceAddIOInProgress(prof.Builder, u.Device[i].IOInProgress)
		flat.DeviceAddIOTime(prof.Builder, u.Device[i].IOTime)
		flat.DeviceAddWeightedIOTime(prof.Builder, u.Device[i].WeightedIOTime)
		devF[i] = flat.DeviceEnd(prof.Builder)
	}
	flat.DiskUsageStartDeviceVector(prof.Builder, len(devF))
	for i := len(devF) - 1; i >= 0; i-- {
		prof.Builder.PrependUOffsetT(devF[i])
	}
	devV := prof.Builder.EndVector(len(devF))
	flat.DiskUsageStart(prof.Builder)
	flat.DiskUsageAddTimestamp(prof.Builder, u.Timestamp)
	flat.DiskUsageAddTimeDelta(prof.Builder, u.TimeDelta)
	flat.DiskUsageAddDevice(prof.Builder, devV)
	prof.Builder.Finish(flat.DiskUsageEnd(prof.Builder))
	p := prof.Builder.Bytes[prof.Builder.Head():]
	// copy them (otherwise gets lost in reset)
	tmp := make([]byte, len(p))
	copy(tmp, p)
	return tmp
}
1341346
func (s *Serializer) Serialize(m telegraf.Metric) ([]byte, error) {
	s.buf.Reset()
	err := s.writeMetric(&s.buf, m)
	if err != nil {
		return nil, err
	}

	out := make([]byte, s.buf.Len())
	copy(out, s.buf.Bytes())
	return out, nil
}
1037871
func Serialize(u *structs.DiskUsage) (p []byte, err error) {
	stdMu.Lock()
	defer stdMu.Unlock()
	if std == nil {
		std, err = NewProfiler()
		if err != nil {
			return nil, err
		}
	}
	return std.Serialize(u), nil
}
370974
func (p *Profiler) SerializeCPU(cpu *cpux.CPU) fb.UOffsetT {
	uoffs := make([]fb.UOffsetT, len(cpu.CacheIDs))
	// serialize cache info in order; the flatbuffer table will have the info
	// in order so a separate cache ID list isn't necessary for flatbuffers.
	for i, id := range cpu.CacheIDs {
		// If the ID doesn't exist, the 0 value will be used
		inf := cpu.Cache[id]
		uoffs[i] = p.SerializeCache(id, inf)
	}
	structs.CPUStartCacheVector(p.Builder, len(uoffs))
	for i := len(uoffs) - 1; i >= 0; i-- {
		p.Builder.PrependUOffsetT(uoffs[i])
	}
	cache := p.Builder.EndVector(len(uoffs))

	structs.CPUStart(p.Builder)
	structs.CPUAddPhysicalPackageID(p.Builder, cpu.PhysicalPackageID)
	structs.CPUAddCoreID(p.Builder, cpu.CoreID)
	structs.CPUAddMHzMin(p.Builder, cpu.MHzMin)
	structs.CPUAddMHzMax(p.Builder, cpu.MHzMax)
	structs.CPUAddCache(p.Builder, cache)
	return structs.CPUEnd(p.Builder)
}
704709
func Serialize(la l.LoadAvg) (p []byte, err error) {
	stdMu.Lock()
	defer stdMu.Unlock()
	if std == nil {
		std, err = NewProfiler()
		if err != nil {
			return nil, err
		}
	}
	return std.Serialize(la)
}
819751
func (t *TxOut) SerializeSize() int {
	// Value 8 bytes + serialized varint size for the length of PkScript +
	// PkScript bytes.
	return 8 + VarIntSerializeSize(uint64(len(t.PkScript))) + len(t.PkScript)
}
664248
func (t *FpdfTpl) Serialize() ([]byte, error) {
	b := new(bytes.Buffer)
	enc := gob.NewEncoder(b)
	err := enc.Encode(t)

	return b.Bytes(), err
}
263596
func (prof *Profiler) Serialize(os *o.OS) ([]byte, error) {
	return json.Marshal(os)
}
1372813
func Serialize(k *v.Kernel) (p []byte, err error) {
	stdMu.Lock()
	defer stdMu.Unlock()
	if std == nil {
		std, err = NewProfiler()
		if err != nil {
			return nil, err
		}
	}
	return std.Serialize(k)
}
1199549
func (p *Profiler) SerializeCPU(cpu *freq.CPU) fb.UOffsetT {
	structs.CPUStart(p.Builder)
	structs.CPUAddProcessor(p.Builder, cpu.Processor)
	structs.CPUAddCPUMHz(p.Builder, cpu.CPUMHz)
	structs.CPUAddPhysicalID(p.Builder, cpu.PhysicalID)
	structs.CPUAddCoreID(p.Builder, cpu.CoreID)
	structs.CPUAddAPICID(p.Builder, cpu.APICID)
	return structs.CPUEnd(p.Builder)
}
204511
func (b *NexthopLookupBody) Serialize(version uint8) ([]byte, error) {
	family := addressFamilyFromApi(b.Api, version)
	buf := make([]byte, 0)

	if family == syscall.AF_INET {
		buf = append(buf, b.Addr.To4()...)
	} else if family == syscall.AF_INET6 {
		buf = append(buf, b.Addr.To16()...)
	}
	return buf, nil
}
252684
func (msg *Message) Serialize() []byte {
	msg.DataLen = msgLenToBytes(int64(len(msg.Data)))
	buf := bytes.NewBuffer([]byte{})
	binary.Write(buf, binary.BigEndian, msg.MessageHeader)
	binary.Write(buf, binary.BigEndian, msg.Data[:])

	return buf.Bytes()
}