func (b *Buffer) Read(data []byte) (int, error) {
	if b.Len() == 0 {
		return 0, io.EOF
	}
	nBytes := copy(data, b.v[b.start:b.end])
	if int32(nBytes) == b.Len() {
		b.Clear()
	} else {
		b.start += int32(nBytes)
	}
	return nBytes, nil
}
Read implements io.Reader.Read().
package buf
import (
	"io"
)
type Supplier func([]byte) (int, error)
type Buffer struct {
	v []byte
	start int32
	end   int32
}
func (b *Buffer) Release() {
	if b == nil || b.v == nil {
		return
	}
	freeBytes(b.v)
	b.v = nil
	b.start = 0
	b.end = 0
}
func (b *Buffer) Clear() {
	b.start = 0
	b.end = 0
}
func (b *Buffer) AppendBytes(bytes ...byte) (int, error) {
	return b.Write(bytes)
}
func (b *Buffer) AppendSupplier(writer Supplier) error {
	nBytes, err := writer(b.v[b.end:])
	b.end += int32(nBytes)
	return err
}
func (b *Buffer) Byte(index int32) byte {
	return b.v[b.start+index]
}
func (b *Buffer) SetByte(index int32, value byte) {
	b.v[b.start+index] = value
}
func (b *Buffer) Bytes() []byte {
	return b.v[b.start:b.end]
}
func (b *Buffer) Reset(writer Supplier) error {
	nBytes, err := writer(b.v)
	b.start = 0
	b.end = int32(nBytes)
	return err
}
func (b *Buffer) BytesRange(from, to int32) []byte {
	if from < 0 {
		from += b.Len()
	}
	if to < 0 {
		to += b.Len()
	}
	return b.v[b.start+from : b.start+to]
}
func (b *Buffer) BytesFrom(from int32) []byte {
	if from < 0 {
		from += b.Len()
	}
	return b.v[b.start+from : b.end]
}
func (b *Buffer) BytesTo(to int32) []byte {
	if to < 0 {
		to += b.Len()
	}
	return b.v[b.start : b.start+to]
}
func (b *Buffer) Resize(from, to int32) {
	if from < 0 {
		from += b.Len()
	}
	if to < 0 {
		to += b.Len()
	}
	if to < from {
		panic("Invalid slice")
	}
	b.end = b.start + to
	b.start += from
}
func (b *Buffer) Advance(from int32) {
	if from < 0 {
		from += b.Len()
	}
	b.start += from
}
func (b *Buffer) Len() int32 {
	if b == nil {
		return 0
	}
	return b.end - b.start
}
func (b *Buffer) IsEmpty() bool {
	return b.Len() == 0
}
func (b *Buffer) IsFull() bool {
	return b.end == int32(len(b.v))
}
func (b *Buffer) Write(data []byte) (int, error) {
	nBytes := copy(b.v[b.end:], data)
	b.end += int32(nBytes)
	return nBytes, nil
}