// toBytes converts a slice of runes to its equivalent in bytes.
553220
func toBytes(runes []rune) []byte {
	var bytes []byte
	char := make([]byte, utf8.UTFMax)

	for _, r := range runes {
		n := utf8.EncodeRune(char, r)
		bytes = append(bytes, char[:n]...)
	}

	return bytes
}
735258
func (c *Client) HMSet(key string, items map[string]string) (err error) {
	tmp := make([]interface{}, (len(items) * 2))
	idx := 0
	for k, v := range items {
		n := idx * 2
		tmp[n] = k
		tmp[n+1] = v
		idx++
	}
	_, err = c.execWithKey(true, "HMSET", key, tmp...)
	return
}
1027687
func (h *Hash) SetBytes(b []byte) {
	if len(b) > len(h) {
		b = b[len(b)-HashLength:]
	}

	copy(h[HashLength-len(b):], b)
}
1014149
func (this *ApnsBatchRequest) ToByte() ([]byte, error) {
	data, err := json.Marshal(this)
	if err != nil {
		return nil, err
	}

	return data, nil
}
462569
func (l DocumentMetaSlice) Keys() []string {
	keys := make([]string, len(l))
	for i, m := range l {
		keys[i] = m.Key
	}
	return keys
}
41
func Digests(key Trits, spongeFunc ...SpongeFunction) (Trits, error) {
	var err error
	fragments := int(math.Floor(float64(len(key)) / KeyFragmentLength))
	digests := make(Trits, fragments*HashTrinarySize)
	buf := make(Trits, HashTrinarySize)

	h := GetSpongeFunc(spongeFunc, kerl.NewKerl)
	defer h.Reset()

	// iterate through each key fragment
	for i := 0; i < fragments; i++ {
		keyFragment := key[i*KeyFragmentLength : (i+1)*KeyFragmentLength]

		// each fragment consists of 27 segments
		for j := 0; j < KeySegmentsPerFragment; j++ {
			copy(buf, keyFragment[j*HashTrinarySize:(j+1)*HashTrinarySize])

			// hash each segment 26 times
			for k := 0; k < KeySegmentHashRounds; k++ {
				h.Absorb(buf)
				buf, err = h.Squeeze(HashTrinarySize)
				if err != nil {
					return nil, err
				}
				h.Reset()
			}

			copy(keyFragment[j*HashTrinarySize:], buf)
		}

		// hash the key fragment (which now consists of hashed segments)
		if err := h.Absorb(keyFragment); err != nil {
			return nil, err
		}

		buf, err := h.Squeeze(HashTrinarySize)
		if err != nil {
			return nil, err
		}

		copy(digests[i*HashTrinarySize:], buf)

		h.Reset()
	}

	return digests, nil
}
118624
func (h *Hash) SetBytes(hash []byte) error {
	if length := len(hash); length != common.HashLength {
		return fmt.Errorf("invalid hash length: %v != %v", length, common.HashLength)
	}
	copy(h.hash[:], hash)
	return nil
}
67351
func (pub *PublicKey) ToBytesUncompressed() (b []byte) {
	/* See Certicom SEC1 2.3.3, pg. 10 */

	x := pub.X.Bytes()
	y := pub.Y.Bytes()

	/* Pad X and Y coordinate bytes to 32-bytes */
	padded_x := append(bytes.Repeat([]byte{0x00}, 32-len(x)), x...)
	padded_y := append(bytes.Repeat([]byte{0x00}, 32-len(y)), y...)

	/* Add prefix 0x04 for uncompressed coordinates */
	return append([]byte{0x04}, append(padded_x, padded_y...)...)
}
437101
func (p *Parser) ParseBytes(b []byte, v interface{}) error {
	return p.Parse(bytes.NewReader(b), v)
}
1244981
func (f *Filter) PBytes() ([]byte, error) {
	filterData := make([]byte, len(f.filterData)+1)
	filterData[0] = f.p
	copy(filterData[1:], f.filterData)
	return filterData, nil
}
1086575
func (s *Image) SetBytes(v []byte) *Image {
	s.Bytes = v
	return s
}
1175149
func formatBytes(i int64) (result string) {
	switch {
	case i >= TiB:
		result = fmt.Sprintf("%.02f TiB", float64(i)/TiB)
	case i >= GiB:
		result = fmt.Sprintf("%.02f GiB", float64(i)/GiB)
	case i >= MiB:
		result = fmt.Sprintf("%.02f MiB", float64(i)/MiB)
	case i >= KiB:
		result = fmt.Sprintf("%.02f KiB", float64(i)/KiB)
	default:
		result = fmt.Sprintf("%d B", i)
	}
	return
}
956817
func (d *adxl345DataFormat) toByte() (bits uint8) {
	bits = 0x00
	bits = bits | (d.selfTest << 7)
	bits = bits | (d.spi << 6)
	bits = bits | (d.intInvert << 5)
	bits = bits | (d.fullRes << 3)
	bits = bits | (d.justify << 2)
	bits = bits | d.sensorRange

	return bits
}
51480
func JSONToBytes(m map[string]interface{}) (*[]byte, error) {
	b, err := json.Marshal(m)
	if err != nil {
		return nil, err
	}

	return &b, nil
}
1132544
func (mmap MarshalMap) Bytes(key string) ([]byte, error) {
	val, exists := mmap.Value(key)
	if !exists {
		return []byte{}, fmt.Errorf(`"%s" is not set`, key)
	}

	bytesValue, isBytes := val.([]byte)
	if !isBytes {
		return []byte{}, fmt.Errorf(`"%s" is expected to be a []byte`, key)
	}
	return bytesValue, nil
}
643346
func (m EncryptedMessage) ToBytes() ([]byte, error) {
	if m.length > math.MaxUint64 {
		return nil, errors.New("The message exceeds the maximum allowed sized: uint64 MAX")
	}

	var buffer bytes.Buffer

	// length
	lengthBytes := smallendian.ToUint64(m.length)
	buffer.Write(lengthBytes[:])

	// nonce
	buffer.Write(m.nonce[:])

	// message
	buffer.Write(m.data)

	return buffer.Bytes(), nil

}
1234486
func (t *fileTracker) SetBytes(bytes map[int]uint64) {
	total := uint64(0)
	labels := t.Labels()
	for k, v := range bytes {
		labels["level"] = fmt.Sprintf("%d", k)
		t.metrics.DiskSize.With(labels).Set(float64(v))
	}
	atomic.StoreUint64(&t.diskBytes, total)
}