Documentation ¶
Overview ¶
Package buffer implements a buffer for serialization, consisting of a chain of []byte-s to reduce copying and to allow reuse of individual chunks.
Index ¶
- type Buffer
- func (b *Buffer) AppendByte(data byte)
- func (b *Buffer) AppendBytes(data []byte)
- func (b *Buffer) AppendString(data string)
- func (b *Buffer) BuildBytes(reuse ...[]byte) []byte
- func (b *Buffer) Bytes() []byte
- func (b *Buffer) DumpTo(w io.Writer) (written int, err error)
- func (b *Buffer) Len() int
- func (b *Buffer) ReadCloser() io.ReadCloser
- func (b *Buffer) ReadFrom(r io.Reader) (int64, error)
- func (b *Buffer) Reset()
- func (b *Buffer) Set(p []byte)
- func (b *Buffer) SetString(s string)
- func (b *Buffer) Size() int
- func (b *Buffer) String() string
- func (b *Buffer) Write(p []byte) (int, error)
- func (b *Buffer) WriteByte(c byte) error
- func (b *Buffer) WriteString(s string) (int, error)
- func (b *Buffer) WriteTo(w io.Writer) (int64, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct { // Buf is a byte buffer to use in append-like workloads. // See example code for details. Buf []byte }
Buffer is a buffer optimized for serialization without extra copying.
func (*Buffer) AppendByte ¶
AppendByte appends a single byte to buffer.
func (*Buffer) AppendBytes ¶
AppendBytes appends a byte slice to buffer.
func (*Buffer) AppendString ¶
AppendString appends a string to buffer.
func (*Buffer) BuildBytes ¶
BuildBytes creates a single byte slice with all the contents of the buffer. Data is copied if it does not fit in a single chunk. You can optionally provide one byte slice as argument that it will try to reuse.
func (*Buffer) Bytes ¶
Bytes returns b.Buf, i.e. all the bytes accumulated in the buffer.
The purpose of this function is bytes.Buffer compatibility.
func (*Buffer) ReadCloser ¶
func (b *Buffer) ReadCloser() io.ReadCloser
ReadCloser creates an io.ReadCloser with all the contents of the buffer.
func (*Buffer) ReadFrom ¶
ReadFrom implements io.ReaderFrom.
The function appends all the data read from r to b.
func (*Buffer) WriteByte ¶
WriteByte appends the byte c to the buffer.
The purpose of this function is bytes.Buffer compatibility.
The function always returns nil.
func (*Buffer) WriteString ¶
WriteString appends s to ByteBuffer.Buf.