func (b *defaultByteBuffer) Flush() (err error) {
	if b.status&BitWritable == 0 {
		return errors.New("unwritable buffer, cannot support Flush")
	}
	return nil
}
Flush writes any malloc data to the underlying io.Writer.
The malloced buffer must be set correctly.
package remote
import (
	"errors"
	"fmt"
	"io"
	"sync"
)
const (
	BitReadable = 1 << iota
	BitWritable
)
var bytebufPool sync.Pool
func init() {
	bytebufPool.New = newDefaultByteBuffer
}
func NewWriterBuffer(size int) ByteBuffer {
	return newWriterByteBuffer(size)
}
func NewReaderBuffer(buf []byte) ByteBuffer {
	return newReaderByteBuffer(buf)
}
func NewReaderWriterBuffer(size int) ByteBuffer {
	return newReaderWriterByteBuffer(size)
}
type defaultByteBuffer struct {
	buff     []byte
	readIdx  int
	writeIdx int
	status   int
}
var _ ByteBuffer = &defaultByteBuffer{}
func newDefaultByteBuffer() interface{} {
	return &defaultByteBuffer{}
}
func newReaderByteBuffer(buf []byte) ByteBuffer {
	bytebuf := bytebufPool.Get().(*defaultByteBuffer)
	bytebuf.buff = buf
	bytebuf.readIdx = 0
	bytebuf.writeIdx = len(buf)
	bytebuf.status = BitReadable
	return bytebuf
}
func newWriterByteBuffer(estimatedLength int) ByteBuffer {
	if estimatedLength <= 0 {
		estimatedLength = 256  
	}
	bytebuf := bytebufPool.Get().(*defaultByteBuffer)
	bytebuf.buff = make([]byte, estimatedLength)
	bytebuf.status = BitWritable
	bytebuf.writeIdx = 0
	return bytebuf
}
func newReaderWriterByteBuffer(estimatedLength int) ByteBuffer {
	if estimatedLength <= 0 {
		estimatedLength = 256  
	}
	bytebuf := bytebufPool.Get().(*defaultByteBuffer)
	bytebuf.buff = make([]byte, estimatedLength)
	bytebuf.readIdx = 0
	bytebuf.writeIdx = 0
	bytebuf.status = BitReadable | BitWritable
	return bytebuf
}
func (b *defaultByteBuffer) Next(n int) (buf []byte, err error) {
	if b.status&BitReadable == 0 {
		return nil, errors.New("unreadable buffer, cannot support Next")
	}
	buf, err = b.Peek(n)
	b.readIdx += n
	return buf, err
}
func (b *defaultByteBuffer) Peek(n int) (buf []byte, err error) {
	if b.status&BitReadable == 0 {
		return nil, errors.New("unreadable buffer, cannot support Peek")
	}
	if err = b.readableCheck(n); err != nil {
		return nil, err
	}
	return b.buff[b.readIdx : b.readIdx+n], nil
}
func (b *defaultByteBuffer) Skip(n int) (err error) {
	if b.status&BitReadable == 0 {
		return errors.New("unreadable buffer, cannot support Skip")
	}
	if err = b.readableCheck(n); err != nil {
		return err
	}
	b.readIdx += n
	return nil
}
func (b *defaultByteBuffer) ReadableLen() (n int) {
	if b.status&BitReadable == 0 {
		return -1
	}
	return b.writeIdx - b.readIdx
}
func (b *defaultByteBuffer) Read(p []byte) (n int, err error) {
	if b.status&BitReadable == 0 {
		return -1, errors.New("unreadable buffer, cannot support Read")
	}
	pl := len(p)
	var buf []byte
	readable := b.ReadableLen()
	if readable == 0 {
		return 0, io.EOF
	}
	if pl <= readable {
		buf, err = b.Next(pl)
		if err != nil {
			return
		}
		n = pl
	} else {
		buf, err = b.Next(readable)
		if err != nil {
			return
		}
		n = readable
	}
	copy(p, buf)
	return
}
func (b *defaultByteBuffer) ReadString(n int) (s string, err error) {
	if b.status&BitReadable == 0 {
		return "", errors.New("unreadable buffer, cannot support ReadString")
	}
	var buf []byte
	if buf, err = b.Next(n); err != nil {
		return "", err
	}
	return string(buf), nil
}
func (b *defaultByteBuffer) ReadBinary(n int) (p []byte, err error) {
	if b.status&BitReadable == 0 {
		return p, errors.New("unreadable buffer, cannot support ReadBinary")
	}
	var buf []byte
	if buf, err = b.Next(n); err != nil {
		return p, err
	}
	p = make([]byte, n)
	copy(p, buf)
	return p, nil
}
func (b *defaultByteBuffer) Malloc(n int) (buf []byte, err error) {
	if b.status&BitWritable == 0 {
		return nil, errors.New("unwritable buffer, cannot support Malloc")
	}
	b.ensureWritable(n)
	currWIdx := b.writeIdx
	b.writeIdx += n
	return b.buff[currWIdx:b.writeIdx], nil
}
func (b *defaultByteBuffer) MallocLen() (length int) {
	if b.status&BitWritable == 0 {
		return -1
	}
	return b.writeIdx
}
func (b *defaultByteBuffer) WriteString(s string) (n int, err error) {
	if b.status&BitWritable == 0 {
		return -1, errors.New("unwritable buffer, cannot support WriteString")
	}
	n = len(s)
	b.ensureWritable(n)
	copy(b.buff[b.writeIdx:b.writeIdx+n], s)
	b.writeIdx += n
	return
}
func (b *defaultByteBuffer) Write(p []byte) (n int, err error) {
	if b.status&BitWritable == 0 {
		return -1, errors.New("unwritable buffer, cannot support Write")
	}
	return b.WriteBinary(p)
}
func (b *defaultByteBuffer) WriteBinary(p []byte) (n int, err error) {
	if b.status&BitWritable == 0 {
		return -1, errors.New("unwritable buffer, cannot support WriteBinary")
	}
	n = len(p)
	b.ensureWritable(n)
	copy(b.buff[b.writeIdx:b.writeIdx+n], p)
	b.writeIdx += n
	return
}
func (b *defaultByteBuffer) ReadLen() (n int) {
	return b.readIdx
}