// Serialize serializes uptime information as Flatbuffers.
422973
func (prof *Profiler) Serialize(up u.Uptime) []byte {
	// ensure the Builder is in a usable state.
	prof.Builder.Reset()
	structs.UptimeStart(prof.Builder)
	structs.UptimeAddTimestamp(prof.Builder, up.Timestamp)
	structs.UptimeAddTotal(prof.Builder, up.Total)
	structs.UptimeAddIdle(prof.Builder, up.Idle)
	prof.Builder.Finish(structs.UptimeEnd(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
}
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
}
1314522
func (s GobSerializer) Serialize(ss *sessions.Session) ([]byte, error) {
	buf := new(bytes.Buffer)
	enc := gob.NewEncoder(buf)
	err := enc.Encode(ss.Values)
	if err == nil {
		return buf.Bytes(), nil
	}
	return nil, err
}
344097
func (s Shard) Serialize() []byte {
	sorted := make([]string, 0, len(s))
	for blob := range s {
		sorted = append(sorted, blob)
	}
	sort.Strings(sorted)
	out := bytes.Buffer{}
	enc := gob.NewEncoder(&out)
	err := enc.Encode(sorted)
	if err != nil {
		panic("impossible error when encoding []string")
	}
	return out.Bytes()
}
637420
func (s SerializeFunc) Serialize(obj interface{}, options ...map[string]interface{}) ([]byte, error) {
	return s(obj, options...)
}
740237
func (record *SignedPreKeyRecord) Serialize() ([]byte, error) {
	b, err := proto.Marshal(record.Spkrs)
	if err != nil {
		return nil, err
	}
	return b, nil
}
1172522
func (h *BlockHeader) Serialize(w io.Writer) error {
	// At the current time, there is no difference between the wire encoding
	// at protocol version 0 and the stable long-term storage format.  As
	// a result, make use of writeBlockHeader.
	return writeBlockHeader(w, 0, h)
}
579542
func (record *PreKeyRecord) Serialize() ([]byte, error) {
	b, err := proto.Marshal(record.Pkrs)
	if err != nil {
		return nil, err
	}
	return b, 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
}
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
}
1248142
func (s SerializableUsageSet) Serialize() []byte {
	sz := 1 + 4 + (len(s) * (32 + 4 + timeSzBytes + timeSzBytes + 4))
	out := make([]byte, sz)
	out[0] = szMemSetHeaderV1
	binary.BigEndian.PutUint32(out[1:], uint32(len(s)))
	p := 5
	for k, entry := range s {
		copy(out[p:], k[:])
		p += 32
		binary.BigEndian.PutUint32(out[p:], uint32(entry.usage))
		p += 4
		created, _ := entry.created.In(time.UTC).MarshalBinary()
		expires, _ := entry.expire.In(time.UTC).MarshalBinary()
		copy(out[p:], created)
		p += len(created)
		copy(out[p:], expires)
		p += len(expires)
		binary.BigEndian.PutUint32(out[p:], uint32(entry.max))
		p += 4
	}
	return out
}
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
}
827374
func (j JSONPBStateSerializer) Serialize(state interface{}) (string, error) {
	pm, ok := state.(proto.Message)
	if ok {
		return j.m.MarshalToString(pm)
	}
	return j.fbss.Serialize(state)
}
676376
func (prof *Profiler) Serialize(f *freq.Frequency) ([]byte, error) {
	return json.Marshal(f)
}
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
}
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
}
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
}