func (ss *sizeSplitterv2) NextBytes() ([]byte, error) {
	if ss.err != nil {
		return nil, ss.err
	}
	full := pool.Get(int(ss.size))
	n, err := io.ReadFull(ss.r, full)
	switch err {
	case io.ErrUnexpectedEOF:
		ss.err = io.EOF
		small := make([]byte, n)
		copy(small, full)
		pool.Put(full)
		return small, nil
	case nil:
		return full, nil
	default:
		pool.Put(full)
		return nil, err
	}
}
NextBytes produces a new chunk.
package chunk
import (
	"io"
	logging "github.com/ipfs/go-log"
	pool "github.com/libp2p/go-buffer-pool"
)
var log = logging.Logger("chunk")
type Splitter interface {
	Reader() io.Reader
	NextBytes() ([]byte, error)
}
type SplitterGen func(r io.Reader) Splitter
func DefaultSplitter(r io.Reader) Splitter {
	return NewSizeSplitter(r, DefaultBlockSize)
}
func SizeSplitterGen(size int64) SplitterGen {
	return func(r io.Reader) Splitter {
		return NewSizeSplitter(r, size)
	}
}
func Chan(s Splitter) (<-chan []byte, <-chan error) {
	out := make(chan []byte)
	errs := make(chan error, 1)
	go func() {
		defer close(out)
		defer close(errs)
		for {
			b, err := s.NextBytes()
			if err != nil {
				errs <- err
				return
			}
			out <- b
		}
	}()
	return out, errs
}
type sizeSplitterv2 struct {
	r    io.Reader
	size uint32
	err  error
}
func NewSizeSplitter(r io.Reader, size int64) Splitter {
	return &sizeSplitterv2{
		r:    r,
		size: uint32(size),
	}
}