// Serialize serializes the shard to a byte buffer.
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()
}
629523
func (prof *Profiler) Serialize(u *structs.DevUsage) ([]byte, error) {
	return json.Marshal(u)
}
748257
func Serialize(st *stats.CPUStats) (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)
}
778635
func Serialize(u *util.CPUUtil) (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
}
538874
func (prof *Profiler) Serialize(cpus *x.CPUs) ([]byte, error) {
	return json.Marshal(cpus)
}
832856
func (op *OpaquePacket) Serialize(w io.Writer) (err error) {
	err = serializeHeader(w, packetType(op.Tag), len(op.Contents))
	if err == nil {
		_, err = w.Write(op.Contents)
	}
	return
}
69151
func (ops *OnePassSignature) Serialize(w io.Writer) error {
	var buf [13]byte
	buf[0] = onePassSignatureVersion
	buf[1] = uint8(ops.SigType)
	var ok bool
	buf[2], ok = s2k.HashToHashId(ops.Hash)
	if !ok {
		return errors.UnsupportedError("hash type: " + strconv.Itoa(int(ops.Hash)))
	}
	buf[3] = uint8(ops.PubKeyAlgo)
	binary.BigEndian.PutUint64(buf[4:12], ops.KeyId)
	if ops.IsLast {
		buf[12] = 1
	}

	if err := serializeHeader(w, packetTypeOnePassSignature, len(buf)); err != nil {
		return err
	}
	_, err := w.Write(buf[:])
	return err
}
750684
func (prof *Profiler) Serialize(inf *structs.DevInfo) ([]byte, error) {
	return json.Marshal(inf)
}
955272
func (uid *UserId) Serialize(w io.Writer) error {
	err := serializeHeader(w, packetTypeUserId, len(uid.Id))
	if err != nil {
		return err
	}
	_, err = w.Write([]byte(uid.Id))
	return err
}
1131540
func (prof *Profiler) Serialize(up u.Uptime) ([]byte, error) {
	return json.Marshal(up)
}
414707
func (prof *Profiler) Serialize(stts *structs.DiskStats) []byte {
	// ensure the Builder is in a usable state.
	prof.Builder.Reset()
	devF := make([]fb.UOffsetT, len(stts.Device))
	names := make([]fb.UOffsetT, len(stts.Device))
	for i := 0; i < len(names); i++ {
		names[i] = prof.Builder.CreateString(stts.Device[i].Name)
	}
	for i := 0; i < len(devF); i++ {
		flat.DeviceStart(prof.Builder)
		flat.DeviceAddMajor(prof.Builder, stts.Device[i].Major)
		flat.DeviceAddMinor(prof.Builder, stts.Device[i].Minor)
		flat.DeviceAddName(prof.Builder, names[i])
		flat.DeviceAddReadsCompleted(prof.Builder, stts.Device[i].ReadsCompleted)
		flat.DeviceAddReadsMerged(prof.Builder, stts.Device[i].ReadsMerged)
		flat.DeviceAddReadSectors(prof.Builder, stts.Device[i].ReadSectors)
		flat.DeviceAddReadingTime(prof.Builder, stts.Device[i].ReadingTime)
		flat.DeviceAddWritesCompleted(prof.Builder, stts.Device[i].WritesCompleted)
		flat.DeviceAddWritesMerged(prof.Builder, stts.Device[i].WritesMerged)
		flat.DeviceAddWrittenSectors(prof.Builder, stts.Device[i].WrittenSectors)
		flat.DeviceAddWritingTime(prof.Builder, stts.Device[i].WritingTime)
		flat.DeviceAddIOInProgress(prof.Builder, stts.Device[i].IOInProgress)
		flat.DeviceAddIOTime(prof.Builder, stts.Device[i].IOTime)
		flat.DeviceAddWeightedIOTime(prof.Builder, stts.Device[i].WeightedIOTime)
		devF[i] = flat.DeviceEnd(prof.Builder)
	}
	flat.DiskStatsStartDeviceVector(prof.Builder, len(devF))
	for i := len(devF) - 1; i >= 0; i-- {
		prof.Builder.PrependUOffsetT(devF[i])
	}
	devV := prof.Builder.EndVector(len(devF))
	flat.DiskStatsStart(prof.Builder)
	flat.DiskStatsAddTimestamp(prof.Builder, stts.Timestamp)
	flat.DiskStatsAddDevice(prof.Builder, devV)
	prof.Builder.Finish(flat.DiskStatsEnd(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
}
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)
}
678442
func (ba *bitArray) Serialize() ([]byte, error) {
	w := new(bytes.Buffer)

	var identifier uint8 = 'B'
	err := binary.Write(w, binary.LittleEndian, identifier)
	if err != nil {
		return nil, err
	}

	err = binary.Write(w, binary.LittleEndian, ba.lowest)
	if err != nil {
		return nil, err
	}
	err = binary.Write(w, binary.LittleEndian, ba.highest)
	if err != nil {
		return nil, err
	}

	var encodedanyset uint8
	if ba.anyset {
		encodedanyset = 1
	} else {
		encodedanyset = 0
	}
	err = binary.Write(w, binary.LittleEndian, encodedanyset)
	if err != nil {
		return nil, err
	}

	err = binary.Write(w, binary.LittleEndian, ba.blocks)
	if err != nil {
		return nil, err
	}
	return w.Bytes(), nil
}
491172
func Serialize(cpus *x.CPUs) (p []byte, err error) {
	stdMu.Lock()
	defer stdMu.Unlock()
	if std == nil {
		std = NewProfiler()
	}
	return std.Serialize(cpus)
}
1351906
func (e *Serializer) Serialize(val interface{}, options ...map[string]interface{}) ([]byte, error) {

	var result []byte
	var err error

	if e.config.Indent {
		result, err = xml.MarshalIndent(val, "", "  ")
		result = append(result, '\n')
	} else {
		result, err = xml.Marshal(val)
	}
	if err != nil {
		return nil, err
	}
	if len(e.config.Prefix) > 0 {
		result = append(e.config.Prefix, result...)
	}
	return result, nil
}
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
	}
}
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
}