// Serialize the memory information using Flatbuffers.
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
}
740237
func (record *SignedPreKeyRecord) Serialize() ([]byte, error) {
	b, err := proto.Marshal(record.Spkrs)
	if err != nil {
		return nil, err
	}
	return b, nil
}
428527
func (r Store) Serialize() []byte {
	w := new(bytes.Buffer)
	enc := gob.NewEncoder(w)
	err := enc.Encode(r)
	if err != nil {
		return nil
	}

	return w.Bytes()
}
1061620
func SerializeThrift(s athrift.TStruct) ([]byte, error) {
	var b []byte
	var buffer = bytes.NewBuffer(b)

	transport := athrift.NewStreamTransportW(buffer)
	if err := s.Write(athrift.NewTBinaryProtocolTransport(transport)); err != nil {
		return nil, err
	}

	if err := transport.Flush(); err != nil {
		return nil, err
	}
	return buffer.Bytes(), nil
}
655234
func Serialize(inf *m.MemInfo) []byte {
	mu.Lock()
	defer mu.Unlock()
	// ensure the Builder is in a usable state.
	builder.Reset()
	structs.MemInfoStart(builder)
	structs.MemInfoAddTimestamp(builder, inf.Timestamp)
	structs.MemInfoAddTotalRAM(builder, inf.TotalRAM)
	structs.MemInfoAddFreeRAM(builder, inf.FreeRAM)
	structs.MemInfoAddSharedRAM(builder, inf.SharedRAM)
	structs.MemInfoAddBufferRAM(builder, inf.BufferRAM)
	structs.MemInfoAddTotalSwap(builder, inf.TotalSwap)
	structs.MemInfoAddFreeSwap(builder, inf.FreeSwap)
	builder.Finish(structs.MemInfoEnd(builder))
	p := builder.Bytes[builder.Head():]
	// copy them (otherwise gets lost in reset)
	tmp := make([]byte, len(p))
	copy(tmp, p)
	return tmp
}
750684
func (prof *Profiler) Serialize(inf *structs.DevInfo) ([]byte, error) {
	return json.Marshal(inf)
}
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
}
124365
func Deserialize(p []byte) *mem.Info {
	infoFlat := structs.GetRootAsInfo(p, 0)
	info := &mem.Info{}
	info.Timestamp = infoFlat.Timestamp()
	info.Active = infoFlat.Active()
	info.ActiveAnon = infoFlat.ActiveAnon()
	info.ActiveFile = infoFlat.ActiveFile()
	info.AnonHugePages = infoFlat.AnonHugePages()
	info.AnonPages = infoFlat.AnonPages()
	info.Bounce = infoFlat.Bounce()
	info.Buffers = infoFlat.Buffers()
	info.Cached = infoFlat.Cached()
	info.CommitLimit = infoFlat.CommitLimit()
	info.CommittedAS = infoFlat.CommittedAS()
	info.DirectMap4K = infoFlat.DirectMap4K()
	info.DirectMap2M = infoFlat.DirectMap2M()
	info.Dirty = infoFlat.Dirty()
	info.HardwareCorrupted = infoFlat.HardwareCorrupted()
	info.HugePagesFree = infoFlat.HugePagesFree()
	info.HugePagesRsvd = infoFlat.HugePagesRsvd()
	info.HugePagesSize = infoFlat.HugePagesSize()
	info.HugePagesSurp = infoFlat.HugePagesSurp()
	info.HugePagesTotal = infoFlat.HugePagesTotal()
	info.Inactive = infoFlat.Inactive()
	info.InactiveAnon = infoFlat.InactiveAnon()
	info.InactiveFile = infoFlat.InactiveFile()
	info.KernelStack = infoFlat.KernelStack()
	info.Mapped = infoFlat.Mapped()
	info.MemAvailable = infoFlat.MemAvailable()
	info.MemFree = infoFlat.MemFree()
	info.MemTotal = infoFlat.MemTotal()
	info.Mlocked = infoFlat.Mlocked()
	info.NFSUnstable = infoFlat.NFSUnstable()
	info.PageTables = infoFlat.PageTables()
	info.Shmem = infoFlat.Shmem()
	info.Slab = infoFlat.Slab()
	info.SReclaimable = infoFlat.SReclaimable()
	info.SUnreclaim = infoFlat.SUnreclaim()
	info.SwapCached = infoFlat.SwapCached()
	info.SwapFree = infoFlat.SwapFree()
	info.SwapTotal = infoFlat.SwapTotal()
	info.Unevictable = infoFlat.Unevictable()
	info.VmallocChunk = infoFlat.VmallocChunk()
	info.VmallocTotal = infoFlat.VmallocTotal()
	info.VmallocUsed = infoFlat.VmallocUsed()
	info.Writeback = infoFlat.Writeback()
	info.WritebackTmp = infoFlat.WritebackTmp()
	return info
}
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
}
1208624
func Serialize(w io.Writer, key []byte, rand io.Reader, passphrase []byte, c *Config) error {
	var buf [11]byte
	buf[0] = 3 /* iterated and salted */
	buf[1], _ = HashToHashId(c.hash())
	salt := buf[2:10]
	if _, err := io.ReadFull(rand, salt); err != nil {
		return err
	}
	encodedCount := c.encodedCount()
	count := decodeCount(encodedCount)
	buf[10] = encodedCount
	if _, err := w.Write(buf[:]); err != nil {
		return err
	}

	Iterated(key, c.hash().New(), passphrase, salt, count)
	return nil
}
52948
func (b *ImportLookupBody) Serialize(version uint8) ([]byte, error) {
	buf := make([]byte, 1)
	buf[0] = b.PrefixLength
	buf = append(buf, b.Addr.To4()...)
	return buf, nil
}
75721
func (prof *Profiler) Serialize(u *util.CPUUtil) []byte {
	// ensure the Builder is in a usable state.
	prof.Builder.Reset()
	utils := make([]fb.UOffsetT, len(u.CPU))
	ids := make([]fb.UOffsetT, len(u.CPU))
	for i := 0; i < len(ids); i++ {
		ids[i] = prof.Builder.CreateString(u.CPU[i].ID)
	}
	for i := 0; i < len(utils); i++ {
		structs.UtilizationStart(prof.Builder)
		structs.UtilizationAddID(prof.Builder, ids[i])
		structs.UtilizationAddUsage(prof.Builder, u.CPU[i].Usage)
		structs.UtilizationAddUser(prof.Builder, u.CPU[i].User)
		structs.UtilizationAddNice(prof.Builder, u.CPU[i].Nice)
		structs.UtilizationAddSystem(prof.Builder, u.CPU[i].System)
		structs.UtilizationAddIdle(prof.Builder, u.CPU[i].Idle)
		structs.UtilizationAddIOWait(prof.Builder, u.CPU[i].IOWait)
		utils[i] = structs.UtilizationEnd(prof.Builder)
	}
	structs.CPUUtilStartCPUVector(prof.Builder, len(utils))
	for i := len(utils) - 1; i >= 0; i-- {
		prof.Builder.PrependUOffsetT(utils[i])
	}
	utilsV := prof.Builder.EndVector(len(utils))
	structs.CPUUtilStart(prof.Builder)
	structs.CPUUtilAddTimestamp(prof.Builder, u.Timestamp)
	structs.CPUUtilAddTimeDelta(prof.Builder, u.TimeDelta)
	structs.CPUUtilAddBTimeDelta(prof.Builder, u.BTimeDelta)
	structs.CPUUtilAddCtxtDelta(prof.Builder, u.CtxtDelta)
	structs.CPUUtilAddProcesses(prof.Builder, u.Processes)
	structs.CPUUtilAddCPU(prof.Builder, utilsV)
	prof.Builder.Finish(structs.CPUUtilEnd(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
}
502310
func Serialize(opts []*UnitOption) io.Reader {
	var buf bytes.Buffer

	if len(opts) == 0 {
		return &buf
	}

	// Index of sections -> ordered options
	idx := map[string][]*UnitOption{}
	// Separately preserve order in which sections were seen
	sections := []string{}
	for _, opt := range opts {
		sec := opt.Section
		if _, ok := idx[sec]; !ok {
			sections = append(sections, sec)
		}
		idx[sec] = append(idx[sec], opt)
	}

	for i, sect := range sections {
		writeSectionHeader(&buf, sect)
		writeNewline(&buf)

		opts := idx[sect]
		for _, opt := range opts {
			writeOption(&buf, opt)
			writeNewline(&buf)
		}
		if i < len(sections)-1 {
			writeNewline(&buf)
		}
	}

	return &buf
}
794787
func (w *Writer) Serialize(v interface{}) *Writer {
	if v == nil {
		w.WriteNil()
	} else if rv, ok := v.(reflect.Value); ok {
		w.WriteValue(rv)
	} else {
		w.WriteValue(reflect.ValueOf(v))
	}
	return w
}
451308
func Serialize(v interface{}, simple bool) []byte {
	return NewWriter(simple).Serialize(v).Bytes()
}
21956
func Serialize(s Serializer) (string, error) {
	w := &standardWriter{}
	if err := s.Serialize(w); err != nil {
		return "", err
	}
	return w.String(), nil
}
1233583
func (key *Key) Serialize() ([]byte, error) {
	// Private keys should be prepended with a single null byte
	keyBytes := key.Key
	if key.IsPrivate {
		keyBytes = append([]byte{0x0}, keyBytes...)
	}

	// Write fields to buffer in order
	buffer := new(bytes.Buffer)
	buffer.Write(key.Version)
	buffer.WriteByte(key.Depth)
	buffer.Write(key.FingerPrint)
	buffer.Write(key.ChildNumber)
	buffer.Write(key.ChainCode)
	buffer.Write(keyBytes)

	// Append the standard doublesha256 checksum
	serializedKey, err := addChecksumToBytes(buffer.Bytes())
	if err != nil {
		return nil, err
	}

	return serializedKey, nil
}