// Serialize serializes the given struct into bytes with protobuf, then base64 encodes it.  The struct passed to Serialize must satisfy proto.Message.
507600
func (p ProtobufStateSerializer) Serialize(state interface{}) (string, error) {
	bin, err := proto.Marshal(state.(proto.Message))
	if err != nil {
		return "", err
	}
	return base64.StdEncoding.EncodeToString(bin), nil
}
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)
}
500368
func (b *HelloBody) Serialize(version uint8) ([]byte, error) {
	if version <= 3 {
		return []byte{uint8(b.RedistDefault)}, nil
	} else { // version >= 4
		var buf []byte
		if version == 4 {
			buf = make([]byte, 3)
		} else if version >= 5 {
			buf = make([]byte, 4)
		}
		buf[0] = uint8(b.RedistDefault)
		binary.BigEndian.PutUint16(buf[1:3], b.Instance)
		if version >= 5 {
			buf[3] = b.ReceiveNotify
		}
		return buf, nil
	}
}
37828
func (prof *Profiler) Serialize(inf *structs.DevInfo) []byte {
	// ensure the Builder is in a usable state.
	prof.Builder.Reset()
	devs := make([]fb.UOffsetT, len(inf.Device))
	names := make([]fb.UOffsetT, len(inf.Device))
	for i := 0; i < len(inf.Device); i++ {
		names[i] = prof.Builder.CreateString(inf.Device[i].Name)
	}
	for i := 0; i < len(inf.Device); i++ {
		flat.DeviceStart(prof.Builder)
		flat.DeviceAddName(prof.Builder, names[i])
		flat.DeviceAddRBytes(prof.Builder, inf.Device[i].RBytes)
		flat.DeviceAddRPackets(prof.Builder, inf.Device[i].RPackets)
		flat.DeviceAddRErrs(prof.Builder, inf.Device[i].RErrs)
		flat.DeviceAddRDrop(prof.Builder, inf.Device[i].RDrop)
		flat.DeviceAddRFIFO(prof.Builder, inf.Device[i].RFIFO)
		flat.DeviceAddRFrame(prof.Builder, inf.Device[i].RFrame)
		flat.DeviceAddRCompressed(prof.Builder, inf.Device[i].RCompressed)
		flat.DeviceAddRMulticast(prof.Builder, inf.Device[i].RMulticast)
		flat.DeviceAddTBytes(prof.Builder, inf.Device[i].TBytes)
		flat.DeviceAddTPackets(prof.Builder, inf.Device[i].TPackets)
		flat.DeviceAddTErrs(prof.Builder, inf.Device[i].TErrs)
		flat.DeviceAddTDrop(prof.Builder, inf.Device[i].TDrop)
		flat.DeviceAddTFIFO(prof.Builder, inf.Device[i].TFIFO)
		flat.DeviceAddTColls(prof.Builder, inf.Device[i].TColls)
		flat.DeviceAddTCarrier(prof.Builder, inf.Device[i].TCarrier)
		flat.DeviceAddTCompressed(prof.Builder, inf.Device[i].TCompressed)
		devs[i] = flat.DeviceEnd(prof.Builder)
	}
	flat.DevInfoStartDeviceVector(prof.Builder, len(devs))
	for i := len(inf.Device) - 1; i >= 0; i-- {
		prof.Builder.PrependUOffsetT(devs[i])
	}
	devsV := prof.Builder.EndVector(len(devs))
	flat.DevInfoStart(prof.Builder)
	flat.DevInfoAddTimestamp(prof.Builder, inf.Timestamp)
	flat.DevInfoAddDevice(prof.Builder, devsV)
	prof.Builder.Finish(flat.DevInfoEnd(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
}
755886
func (k *Keyring) Serialize() ([]byte, error) {
	// Create the encoded entry
	enc := EncodedKeyring{
		MasterKey: k.masterKey,
	}
	for _, key := range k.keys {
		enc.Keys = append(enc.Keys, key)
	}

	// JSON encode the keyring
	buf, err := json.Marshal(enc)
	return buf, err
}
474998
func Serialize(name string, conf common.Conf) ([]byte, error) {
	var buf bytes.Buffer
	if conf.Transient {
		if err := transientConfT.Execute(&buf, conf); err != nil {
			return nil, err
		}
	} else {
		if err := confT.Execute(&buf, conf); err != nil {
			return nil, err
		}
	}
	return buf.Bytes(), nil
}
135015
func (e *Serializer) Serialize(val interface{}, options ...map[string]interface{}) ([]byte, error) {
	var result []byte
	var err error
	if e.config.Indent {
		result, err = json.MarshalIndent(val, "", "  ")
	} else {
		result, err = json.Marshal(val)
	}

	if err != nil {
		return nil, err
	}

	// the config's callback can be overriden with the options
	callback := e.config.Callback
	if len(options) > 0 {
		callback = e.getCallbackOption(options[0])
	}

	if callback != "" {
		result = append([]byte(callback+"("), result...)
		result = append(result, finishCallbackB...)
	}

	if e.config.Indent {
		result = append(result, newLineB...)
	}
	return result, nil
}
637420
func (s SerializeFunc) Serialize(obj interface{}, options ...map[string]interface{}) ([]byte, error) {
	return s(obj, options...)
}
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
}
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)
}
664248
func (t *FpdfTpl) Serialize() ([]byte, error) {
	b := new(bytes.Buffer)
	enc := gob.NewEncoder(b)
	err := enc.Encode(t)

	return b.Bytes(), err
}
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
}
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)
}
697966
func (l *bunyanLog) serialize(key string, value interface{}) interface{} {
	if fn, ok := l.logger.serializers[key]; ok {
		return fn(value)
	} else if isError(value) {
		return fmt.Sprintf("%v", value)
	} else {
		return value
	}
}
199151
func Serialize(cpus *cpux.CPUs) (p []byte) {
	stdMu.Lock()
	defer stdMu.Unlock()
	if std == nil {
		std = NewProfiler()
	}
	return std.Serialize(cpus)
}
706867
func (e NopEncoder) Serialize(src interface{}) ([]byte, error) {
	if b, ok := src.([]byte); ok {
		return b, nil
	}

	return nil, errValueNotByte
}
629523
func (prof *Profiler) Serialize(u *structs.DevUsage) ([]byte, error) {
	return json.Marshal(u)
}