// Encode a slice of bytes ([]byte).
357913
func (o *Buffer) enc_slice_byte(p *Properties, base structPointer) error {
	s := *structPointer_Bytes(base, p.field)
	if s == nil {
		return ErrNil
	}
	o.buf = append(o.buf, p.tagcode...)
	o.EncodeRawBytes(s)
	return nil
}
1309163
func (mock *Mock) Encode(data []*FileDataEntry) ([]byte, error) {
	items := mock.getReturnValues("Decode")
	if len(items) == 1 {
		switch typed := items[0].(type) {
		case []byte:
			return typed, nil
		case error:
			return []byte{}, typed
		}
	} else if len(items) == 2 {
		return items[0].([]byte), items[1].(error)
	}
	return []byte{}, nil
}
1046887
func Encode(w io.Writer, v interface{}, order binary.ByteOrder) (int, error) {
	b, err := json.Marshal(v)
	if err != nil {
		return 0, err
	}
	return Write(w, bytes.NewReader(b), order)
}
1030255
func (e *Error) Encode(w io.Writer, prver uint32) error {
	return WriteElements(w,
		e.Code,
		e.Data,
	)
}
864944
func (codec *SyncCodec) Encode(data interface{}, out *ByteBuf) error {
	if msg, ok := data.(*notifyRaw); ok {
		out.WriteByte(cmdNotifyRaw)
		out.WriteByteBuf(msg.buf)
		releaseNotifyRaw(msg)
		return nil
	} else if msg, ok := data.(*notify); ok {
		out.WriteByte(cmdNotify)
		out.WriteUint64(msg.offset)
		releaseNotify(msg)
		return nil
	} else if msg, ok := data.(*notifySync); ok {
		out.WriteByte(cmdNotifySync)
		out.WriteUint64(msg.offset)
		releaseNotifySync(msg)
		return nil
	} else if msg, ok := data.(*notifySyncRsp); ok {
		out.WriteByte(cmdNotifySyncRsp)
		out.WriteUint64(msg.offset)
		out.WriteByte(msg.count)
		out.WriteByteBuf(msg.buf)
		releaseNotifySyncRsp(msg)
		return nil
	} else if msg, ok := data.(*notifyHB); ok {
		out.WriteByte(cmdNotifyHB)
		out.WriteUint64(msg.offset)
		return nil
	}

	return fmt.Errorf("not support msg: %v", data)
}
1221160
func Encode(dst, src []byte) ([]byte, error) {
	if n := MaxEncodedLen(len(src)); len(dst) < n {
		dst = make([]byte, n)
	}

	var srcPtr unsafe.Pointer
	if len(src) != 0 {
		srcPtr = unsafe.Pointer(&src[0])
	}

	dLen := C.size_t(len(dst))
	status := C.snappy_compress((*C.char)(srcPtr), C.size_t(len(src)),
		(*C.char)(unsafe.Pointer(&dst[0])), &dLen)
	if status != C.SNAPPY_OK {
		return nil, ErrCorrupt
	}

	return dst[:dLen], nil
}
123744
func encode(body interface{}) io.Reader {
	var b bytes.Buffer
	err := json.NewEncoder(&b).Encode(body)
	if err != nil {
		return errorReader{err}
	}
	return &b
}
1157808
func (e *Encoder) Encode(v interface{}) error {
	val := reflect.ValueOf(v)
	return e.encode(val)
}
481744
func Encode(g geom.T, byteOrder binary.ByteOrder) (string, error) {
	wkb, err := wkb.Marshal(g, byteOrder)
	if err != nil {
		return "", err
	}
	return hex.EncodeToString(wkb), nil
}
1102564
func (jsonEncoder) Encode(v ...interface{}) string {
	var data interface{} = v
	if v == nil {
		// So that empty results produces `[]` and not `null`
		data = []interface{}{}
	} else if len(v) == 1 {
		data = v[0]
	}
	b, err := json.Marshal(data)
	if err != nil {
		panic(err)
	}
	log.Printf("%s", b)
	return string(b)
}
123078
func EncodeBytes(data []byte) string {
	mt := http.DetectContentType(data)
	// http.DetectContentType may add spurious spaces between ; and a parameter.
	// The canonical way is to not have them.
	cleanedMt := strings.Replace(mt, "; ", ";", -1)

	return New(data, cleanedMt).String()
}
331777
func Encode(data []byte, fragmentSize, redundancy int) ([][]byte, error) {
	if len(data)%fragmentSize != 0 {
		return nil, errors.New("length of data must be a multiple of the given fragment-size")
	}

	// fragment the data into rows
	var dataRows [][]byte
	for i := 0; i < len(data)/fragmentSize; i++ {
		offset := i * fragmentSize
		dataRows = append(dataRows, data[offset:offset+fragmentSize])
	}
	w := len(dataRows)

	for y := 0; y < redundancy; y++ {
		s := make([]byte, fragmentSize)
		a := matrixLine(y+1, w)

		for x := 0; x < w; x++ {
			if a[x] == 1 {
				for m := 0; m < fragmentSize; m++ {
					s[m] ^= dataRows[x][m]
				}
			}
		}

		dataRows = append(dataRows, s)
	}

	return dataRows, nil
}
468302
func EncodeToBytes(val interface{}) ([]byte, error) {
	eb := encbufPool.Get().(*encbuf)
	defer encbufPool.Put(eb)
	eb.reset()
	if err := eb.encode(val); err != nil {
		return nil, err
	}
	return eb.toBytes(), nil
}
764093
func (s ISO88595) Encode() []byte {
	e := charmap.ISO8859_5.NewEncoder()
	es, _, err := transform.Bytes(e, s)
	if err != nil {
		return s
	}
	return es
}
414307
func Encode(src []byte) []byte {
	buf := make([]byte, Encoding.EncodedLen(len(src)))
	Encoding.Encode(buf, src)
	return buf
}
1268149
func (r *OffsetResponse) encode(pe packetEncoder) (err error) {
	if err = pe.putArrayLength(len(r.Blocks)); err != nil {
		return err
	}

	for topic, partitions := range r.Blocks {
		if err = pe.putString(topic); err != nil {
			return err
		}
		if err = pe.putArrayLength(len(partitions)); err != nil {
			return err
		}
		for partition, block := range partitions {
			pe.putInt32(partition)
			if err = block.encode(pe, r.version()); err != nil {
				return err
			}
		}
	}

	return nil
}
396038
func Encode(data []byte) (*Encodings, error) {
	code, err := qr.Encode(string(data), qr.L)
	if err != nil {
		return nil, err
	}

	var result Encodings
	result.PNG = code.PNG()
	result.Terminal = terminal(code)
	result.ASCII = ascii(code)

	return &result, nil
}