Documentation ¶
Index ¶
- type ReadWriteBuffer
- func (rw *ReadWriteBuffer) Bytes() []byte
- func (rw *ReadWriteBuffer) Len() int
- func (rw *ReadWriteBuffer) Read(b []byte) (n int, err error)
- func (rw *ReadWriteBuffer) ReadAt(b []byte, off int64) (n int, err error)
- func (rw *ReadWriteBuffer) Reset(b []byte)
- func (rw *ReadWriteBuffer) Seek(offset int64, whence int) (int64, error)
- func (rw *ReadWriteBuffer) SetMax(max int)
- func (rw *ReadWriteBuffer) Shape() (int, int)
- func (rw *ReadWriteBuffer) Size() int64
- func (rw *ReadWriteBuffer) WriteAt(dat []byte, off int64) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ReadWriteBuffer ¶
type ReadWriteBuffer struct {
// contains filtered or unexported fields
}
ReadWriteBuffer is a simple type that implements io.WriterAt on an in-memory buffer. The zero value of this type is an empty buffer ready to use.
func NewReadWriteBuffer ¶
func NewReadWriteBuffer(size, max int) *ReadWriteBuffer
NewReadWriteBuffer creates and returns a new ReadWriteBuffer with the given initial size and maximum. If maximum is <= 0 it is unlimited.
func (*ReadWriteBuffer) Bytes ¶
func (rw *ReadWriteBuffer) Bytes() []byte
Bytes returns the ReadWriteBuffer's underlying data. This value will remain valid so long as no other methods are called on the ReadWriteBuffer.
func (*ReadWriteBuffer) Len ¶
func (rw *ReadWriteBuffer) Len() int
Len returns the number of bytes of the unread portion of the slice.
func (*ReadWriteBuffer) Read ¶
func (rw *ReadWriteBuffer) Read(b []byte) (n int, err error)
Read implements the io.Reader interface.
func (*ReadWriteBuffer) ReadAt ¶
func (rw *ReadWriteBuffer) ReadAt(b []byte, off int64) (n int, err error)
ReadAt implements the io.ReaderAt interface.
func (*ReadWriteBuffer) Reset ¶
func (rw *ReadWriteBuffer) Reset(b []byte)
Reset resets the Reader to be reading from b.
func (*ReadWriteBuffer) Seek ¶
func (rw *ReadWriteBuffer) Seek(offset int64, whence int) (int64, error)
Seek implements the io.Seeker interface.
func (*ReadWriteBuffer) SetMax ¶
func (rw *ReadWriteBuffer) SetMax(max int)
SetMax sets the maximum capacity of the ReadWriteBuffer. If the provided maximum is lower than the current capacity but greater than 0 it is set to the current capacity, if less than or equal to zero it is unlimited..
func (*ReadWriteBuffer) Shape ¶
func (rw *ReadWriteBuffer) Shape() (int, int)
Shape returns the current ReadWriteBuffer size and its maximum if one was provided.
func (*ReadWriteBuffer) Size ¶
func (rw *ReadWriteBuffer) Size() int64
Size returns the original length of the underlying byte slice. Size is the number of bytes available for reading via ReadAt. The returned value is always the same and is not affected by calls to any other method.