Diff

Differences From Artifact [f63ac1dff8]:

To Artifact [98f8caa018]:


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
type ReaderFunc func([]byte) (int, error)

// Delegates the call to the WriterFunc while implementing io.Reader
func (r ReaderFunc) Read(b []byte) (int, error) {
	return r(b)
}

// Returns a reader that will delegate calls to Read(...) while ensuring
// that the output buffer will never be smaller than the required size
// and will be downsized to a multiple of the required size if larger
func BlockReader(reader io.Reader, size int) io.Reader {
	var buffer []byte = make([]byte, 0, size)

	return ReaderFunc(func(output []byte) (int, error) {
		var (
			readCount int
			err       error
		)







|
|
|
|







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
type ReaderFunc func([]byte) (int, error)

// Delegates the call to the WriterFunc while implementing io.Reader
func (r ReaderFunc) Read(b []byte) (int, error) {
	return r(b)
}

// Returns a reader that delegates calls to Read(...) while ensuring
// that the output buffer is never smaller than the required size
// and is downsized to a multiple of the required size if larger
func SizedReader(reader io.Reader, size int) io.Reader {
	var buffer []byte = make([]byte, 0, size)

	return ReaderFunc(func(output []byte) (int, error) {
		var (
			readCount int
			err       error
		)