func decode(buf []byte, in decoder) error {
	if buf == nil {
		return nil
	}
	helper := realDecoder{raw: buf}
	err := in.decode(&helper)
	if err != nil {
		return err
	}
	if helper.off != len(buf) {
		return DecodingError{Info: "Length was invalid"}
	}
	return nil
}
Decode takes bytes and a Decoder and fills the fields of the decoder from the bytes,
interpreted using Kafka's encoding rules.
package sarama
type encoder interface {
	encode(pe packetEncoder) error
}
func encode(in encoder) ([]byte, error) {
	if in == nil {
		return nil, nil
	}
	var prepEnc prepEncoder
	var realEnc realEncoder
	err := in.encode(&prepEnc)
	if err != nil {
		return nil, err
	}
	realEnc.raw = make([]byte, prepEnc.length)
	err = in.encode(&realEnc)
	if err != nil {
		return nil, err
	}
	return realEnc.raw, nil
}
type decoder interface {
	decode(pd packetDecoder) error
}