// Serialize cpux.CPUs using the package global profiler.
199151
func Serialize(cpus *cpux.CPUs) (p []byte) {
	stdMu.Lock()
	defer stdMu.Unlock()
	if std == nil {
		std = NewProfiler()
	}
	return std.Serialize(cpus)
}
878003
func (n *RegisteredNexthop) Serialize() ([]byte, error) {
	// Connected (1 byte)
	buf := make([]byte, 4)
	buf[0] = byte(n.Connected)

	// Address Family (2 bytes)
	binary.BigEndian.PutUint16(buf[1:3], n.Family)
	// Prefix Length (1 byte)
	addrByteLen, err := addressByteLength(uint8(n.Family))
	if err != nil {
		return nil, err
	}

	buf[3] = byte(addrByteLen * 8)
	// Prefix (variable)
	switch n.Family {
	case uint16(syscall.AF_INET):
		buf = append(buf, n.Prefix.To4()...)
	case uint16(syscall.AF_INET6):
		buf = append(buf, n.Prefix.To16()...)
	default:
		return nil, fmt.Errorf("invalid address family: %d", n.Family)
	}

	return buf, nil
}
418607
func (prof *Profiler) Serialize(inf *info.CPUInfo) ([]byte, error) {
	return json.Marshal(inf)
}
1024977
func (prof *Profiler) Marshal(ut *util.CPUUtil) ([]byte, error) {
	return prof.Serialize(ut)
}
1246498
func (p *Profiler) Serialize(f *freq.Frequency) []byte {
	// ensure the Builder is in a usable state.
	p.Builder.Reset()
	uoffs := make([]fb.UOffsetT, len(f.CPU))
	for i, cpu := range f.CPU {
		uoffs[i] = p.SerializeCPU(&cpu)
	}
	structs.FrequencyStartCPUVector(p.Builder, len(uoffs))
	for i := len(uoffs) - 1; i >= 0; i-- {
		p.Builder.PrependUOffsetT(uoffs[i])
	}
	cpusV := p.Builder.EndVector(len(uoffs))
	structs.FrequencyStart(p.Builder)
	structs.FrequencyAddTimestamp(p.Builder, f.Timestamp)
	structs.FrequencyAddSockets(p.Builder, f.Sockets)
	structs.FrequencyAddCPU(p.Builder, cpusV)
	p.Builder.Finish(structs.FrequencyEnd(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
}
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)
}
17676
func (prof *Profiler) Serialize(inf *mem.Info) []byte {
	// ensure the Builder is in a usable state.
	prof.Builder.Reset()
	structs.InfoStart(prof.Builder)
	structs.InfoAddTimestamp(prof.Builder, inf.Timestamp)
	structs.InfoAddActive(prof.Builder, inf.Active)
	structs.InfoAddActiveAnon(prof.Builder, inf.ActiveAnon)
	structs.InfoAddActiveFile(prof.Builder, inf.ActiveFile)
	structs.InfoAddAnonHugePages(prof.Builder, inf.AnonHugePages)
	structs.InfoAddAnonPages(prof.Builder, inf.AnonPages)
	structs.InfoAddBounce(prof.Builder, inf.Bounce)
	structs.InfoAddBuffers(prof.Builder, inf.Buffers)
	structs.InfoAddCached(prof.Builder, inf.Cached)
	structs.InfoAddCommitLimit(prof.Builder, inf.CommitLimit)
	structs.InfoAddCommittedAS(prof.Builder, inf.CommittedAS)
	structs.InfoAddDirectMap4K(prof.Builder, inf.DirectMap4K)
	structs.InfoAddDirectMap2M(prof.Builder, inf.DirectMap2M)
	structs.InfoAddDirty(prof.Builder, inf.Dirty)
	structs.InfoAddHardwareCorrupted(prof.Builder, inf.HardwareCorrupted)
	structs.InfoAddHugePagesFree(prof.Builder, inf.HugePagesFree)
	structs.InfoAddHugePagesRsvd(prof.Builder, inf.HugePagesRsvd)
	structs.InfoAddHugePagesSize(prof.Builder, inf.HugePagesSize)
	structs.InfoAddHugePagesSurp(prof.Builder, inf.HugePagesSurp)
	structs.InfoAddHugePagesTotal(prof.Builder, inf.HugePagesTotal)
	structs.InfoAddInactive(prof.Builder, inf.Inactive)
	structs.InfoAddInactiveAnon(prof.Builder, inf.InactiveAnon)
	structs.InfoAddInactiveFile(prof.Builder, inf.InactiveFile)
	structs.InfoAddKernelStack(prof.Builder, inf.KernelStack)
	structs.InfoAddMapped(prof.Builder, inf.Mapped)
	structs.InfoAddMemAvailable(prof.Builder, inf.MemAvailable)
	structs.InfoAddMemFree(prof.Builder, inf.MemFree)
	structs.InfoAddMemTotal(prof.Builder, inf.MemTotal)
	structs.InfoAddMlocked(prof.Builder, inf.Mlocked)
	structs.InfoAddNFSUnstable(prof.Builder, inf.NFSUnstable)
	structs.InfoAddPageTables(prof.Builder, inf.PageTables)
	structs.InfoAddShmem(prof.Builder, inf.Shmem)
	structs.InfoAddSlab(prof.Builder, inf.Slab)
	structs.InfoAddSReclaimable(prof.Builder, inf.SReclaimable)
	structs.InfoAddSUnreclaim(prof.Builder, inf.SUnreclaim)
	structs.InfoAddSwapCached(prof.Builder, inf.SwapCached)
	structs.InfoAddSwapFree(prof.Builder, inf.SwapFree)
	structs.InfoAddSwapTotal(prof.Builder, inf.SwapTotal)
	structs.InfoAddUnevictable(prof.Builder, inf.Unevictable)
	structs.InfoAddVmallocChunk(prof.Builder, inf.VmallocChunk)
	structs.InfoAddVmallocTotal(prof.Builder, inf.VmallocTotal)
	structs.InfoAddVmallocUsed(prof.Builder, inf.VmallocUsed)
	structs.InfoAddWriteback(prof.Builder, inf.Writeback)
	structs.InfoAddWritebackTmp(prof.Builder, inf.WritebackTmp)
	prof.Builder.Finish(structs.InfoEnd(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
}
444929
func (b *NexthopUpdateBody) Serialize(version uint8) ([]byte, error) {
	// Address Family (2 bytes)
	buf := make([]byte, 3)
	binary.BigEndian.PutUint16(buf, uint16(b.Prefix.Family))
	addrByteLen, err := addressByteLength(b.Prefix.Family)
	if err != nil {
		return nil, err
	}

	buf[2] = byte(addrByteLen * 8)
	// Prefix Length (1 byte) + Prefix (variable)
	switch b.Prefix.Family {
	case syscall.AF_INET:
		buf = append(buf, b.Prefix.Prefix.To4()...)
	case syscall.AF_INET6:
		buf = append(buf, b.Prefix.Prefix.To16()...)
	default:
		return nil, fmt.Errorf("invalid address family: %d", b.Prefix.Family)
	}
	if version >= 5 {
		// Type (1 byte) (if version>=5)
		// Instance (2 bytes) (if version>=5)
		buf = append(buf, byte(b.Type))
		bbuf := make([]byte, 2)
		binary.BigEndian.PutUint16(bbuf, b.Instance)
		buf = append(buf, bbuf...)
	}
	if version >= 4 {
		// Distance (1 byte) (if version>=4)
		buf = append(buf, b.Distance)
	}
	// Metric (4 bytes)
	bbuf := make([]byte, 4)
	binary.BigEndian.PutUint32(bbuf, b.Metric)
	buf = append(buf, bbuf...)
	// Number of Nexthops (1 byte)
	buf = append(buf, uint8(0)) // Temporary code
	// ToDo Processing Route Entry

	return buf, nil
}
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
}
894269
func (p *PodContainer) CPUs(cpu float64) *PodContainer {
	p.Resources.Cpus = cpu
	return p
}
1041845
func (prof *Profiler) Serialize(u *structs.DevUsage) []byte {
	// ensure the Builder is in a usable state.
	prof.Builder.Reset()
	devs := make([]fb.UOffsetT, len(u.Device))
	names := make([]fb.UOffsetT, len(u.Device))
	for i := 0; i < len(u.Device); i++ {
		names[i] = prof.Builder.CreateString(u.Device[i].Name)
	}
	for i := 0; i < len(u.Device); i++ {
		flat.DeviceStart(prof.Builder)
		flat.DeviceAddName(prof.Builder, names[i])
		flat.DeviceAddRBytes(prof.Builder, u.Device[i].RBytes)
		flat.DeviceAddRPackets(prof.Builder, u.Device[i].RPackets)
		flat.DeviceAddRErrs(prof.Builder, u.Device[i].RErrs)
		flat.DeviceAddRDrop(prof.Builder, u.Device[i].RDrop)
		flat.DeviceAddRFIFO(prof.Builder, u.Device[i].RFIFO)
		flat.DeviceAddRFrame(prof.Builder, u.Device[i].RFrame)
		flat.DeviceAddRCompressed(prof.Builder, u.Device[i].RCompressed)
		flat.DeviceAddRMulticast(prof.Builder, u.Device[i].RMulticast)
		flat.DeviceAddTBytes(prof.Builder, u.Device[i].TBytes)
		flat.DeviceAddTPackets(prof.Builder, u.Device[i].TPackets)
		flat.DeviceAddTErrs(prof.Builder, u.Device[i].TErrs)
		flat.DeviceAddTDrop(prof.Builder, u.Device[i].TDrop)
		flat.DeviceAddTFIFO(prof.Builder, u.Device[i].TFIFO)
		flat.DeviceAddTColls(prof.Builder, u.Device[i].TColls)
		flat.DeviceAddTCarrier(prof.Builder, u.Device[i].TCarrier)
		flat.DeviceAddTCompressed(prof.Builder, u.Device[i].TCompressed)
		devs[i] = flat.DeviceEnd(prof.Builder)
	}
	flat.DevUsageStartDeviceVector(prof.Builder, len(devs))
	for i := len(u.Device) - 1; i >= 0; i-- {
		prof.Builder.PrependUOffsetT(devs[i])
	}
	devsV := prof.Builder.EndVector(len(devs))
	flat.DevUsageStart(prof.Builder)
	flat.DevUsageAddTimestamp(prof.Builder, u.Timestamp)
	flat.DevUsageAddTimeDelta(prof.Builder, u.TimeDelta)
	flat.DevUsageAddDevice(prof.Builder, devsV)
	prof.Builder.Finish(flat.DevUsageEnd(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
}
1154646
func (prof *Profiler) Serialize(stts *stats.CPUStats) []byte {
	// ensure the Builder is in a usable state.
	prof.Builder.Reset()
	cpusF := make([]fb.UOffsetT, len(stts.CPU))
	ids := make([]fb.UOffsetT, len(stts.CPU))
	for i := 0; i < len(ids); i++ {
		ids[i] = prof.Builder.CreateString(stts.CPU[i].ID)
	}
	for i := 0; i < len(cpusF); i++ {
		structs.CPUStart(prof.Builder)
		structs.CPUAddID(prof.Builder, ids[i])
		structs.CPUAddUser(prof.Builder, stts.CPU[i].User)
		structs.CPUAddNice(prof.Builder, stts.CPU[i].Nice)
		structs.CPUAddSystem(prof.Builder, stts.CPU[i].System)
		structs.CPUAddIdle(prof.Builder, stts.CPU[i].Idle)
		structs.CPUAddIOWait(prof.Builder, stts.CPU[i].IOWait)
		structs.CPUAddIRQ(prof.Builder, stts.CPU[i].IRQ)
		structs.CPUAddSoftIRQ(prof.Builder, stts.CPU[i].SoftIRQ)
		structs.CPUAddSteal(prof.Builder, stts.CPU[i].Steal)
		structs.CPUAddQuest(prof.Builder, stts.CPU[i].Quest)
		structs.CPUAddQuestNice(prof.Builder, stts.CPU[i].QuestNice)
		cpusF[i] = structs.CPUEnd(prof.Builder)
	}
	structs.CPUStatsStartCPUVector(prof.Builder, len(cpusF))
	for i := len(cpusF) - 1; i >= 0; i-- {
		prof.Builder.PrependUOffsetT(cpusF[i])
	}
	cpusV := prof.Builder.EndVector(len(cpusF))
	structs.CPUStatsStart(prof.Builder)
	structs.CPUStatsAddClkTck(prof.Builder, stts.ClkTck)
	structs.CPUStatsAddTimestamp(prof.Builder, stts.Timestamp)
	structs.CPUStatsAddCtxt(prof.Builder, stts.Ctxt)
	structs.CPUStatsAddBTime(prof.Builder, stts.BTime)
	structs.CPUStatsAddProcesses(prof.Builder, stts.Processes)
	structs.CPUStatsAddCPU(prof.Builder, cpusV)
	prof.Builder.Finish(structs.CPUStatsEnd(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
}
1065192
func (s CPUSet) Clone() CPUSet {
	b := NewBuilder()
	for elem := range s.elems {
		b.Add(elem)
	}
	return b.Result()
}
864631
func (prof *Profiler) Serialize(inf *basic.Info) []byte {
	// ensure the Builder is in a usable state.
	prof.Builder.Reset()
	structs.InfoStart(prof.Builder)
	structs.InfoAddTimestamp(prof.Builder, inf.Timestamp)
	structs.InfoAddActive(prof.Builder, inf.Active)
	structs.InfoAddInactive(prof.Builder, inf.Inactive)
	structs.InfoAddMapped(prof.Builder, inf.Mapped)
	structs.InfoAddMemAvailable(prof.Builder, inf.MemAvailable)
	structs.InfoAddMemFree(prof.Builder, inf.MemFree)
	structs.InfoAddMemTotal(prof.Builder, inf.MemTotal)
	structs.InfoAddSwapCached(prof.Builder, inf.SwapCached)
	structs.InfoAddSwapFree(prof.Builder, inf.SwapFree)
	structs.InfoAddSwapTotal(prof.Builder, inf.SwapTotal)
	prof.Builder.Finish(structs.InfoEnd(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
}
204922
func Serialize(proc *procs.Processors) (p []byte, err error) {
	stdMu.Lock()
	defer stdMu.Unlock()
	if std == nil {
		std, err = NewProfiler()
		if err != nil {
			return nil, err
		}
	}
	return std.Serialize(proc)
}
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)
}
364125
func (prof *Profiler) Serialize(st *structs.DiskStats) ([]byte, error) {
	return json.Marshal(st)
}