Documentation
¶
Index ¶
- func Put(cb *Buffer)
- type Buffer
- func (cb *Buffer) Len() int
- func (cb *Buffer) MustClose()
- func (cb *Buffer) MustReadAt(p []byte, off int64)
- func (cb *Buffer) MustWrite(p []byte)
- func (cb *Buffer) MustWriteTo(w io.Writer)
- func (cb *Buffer) NewReader() filestream.ReadCloser
- func (cb *Buffer) Path() string
- func (cb *Buffer) ReadFrom(r io.Reader) (int64, error)
- func (cb *Buffer) Reset()
- func (cb *Buffer) SizeBytes() int
- func (cb *Buffer) Write(p []byte) (int, error)
- func (cb *Buffer) WriteTo(w io.Writer) (int64, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer provides in-memory buffer optimized for storing big bytes volumes.
It stores the data in chunks of fixed size. This reduces memory fragmentation and memory waste comparing to the contiguous slices of bytes.
func Get ¶ added in v1.102.18
func Get() *Buffer
Get returns Buffer from the pool.
Return back the Buffer to the pool via Put() call when it is no longer needed.
func (*Buffer) MustReadAt ¶
MustReadAt reads len(p) bytes from cb at the offset off.
func (*Buffer) MustWriteTo ¶ added in v1.102.18
MustWriteTo writes cb contents w.
Use this function only if w cannot return errors. For example, if w is bytes.Buffer of bytesutil.ByteBuffer. If w can return errors, then use WriteTo function instead.
func (*Buffer) NewReader ¶
func (cb *Buffer) NewReader() filestream.ReadCloser
NewReader returns a reader for reading the data stored in cb.
func (*Buffer) ReadFrom ¶ added in v1.102.18
ReadFrom reads all the data from r and appends it to cb.
func (*Buffer) Reset ¶
func (cb *Buffer) Reset()
Reset resets the cb, so it can be reused for writing new data into it.
Reset frees up memory chunks allocated for cb, so they could be reused by other Buffer instances.