Documentation
¶
Overview ¶
Package buffer is a bytes buffer. The ringBuffer is implements Buffer interface by a ring loop bytes buffer.
Index ¶
Constants ¶
View Source
const DefaultBufferCapacity = 4096
DefaultBufferCapacity is default buffer Capacity
Variables ¶
View Source
var ErrBufferCapacityNotEnough = errors.New("buffer capacity is not enough")
ErrBufferCapacityNotEnough is defined error of buffer full When write bytes to buffer and buffer remain space not enough this error will throw.
Functions ¶
Types ¶
type Buffer ¶
type Buffer interface {
// NextN is get next n bytes in buffer
// This method will return count and next bytes.
// This method not move bytes pointer.
NextN(n int) (int, []byte)
// ShiftN is move bytes pointer forward
ShiftN(n int) int
// ReadN is get next bytes in buffer and move bytes pointer forward.
ReadN(n int) (int, []byte)
// Size will return bytes length in buffer
Size() int
// Capacity will return the buffer capacity
Capacity() int
// Write will write bytes to buffer
// When buffer full will throw ErrBufferCapacityNotEnough error
Write(p []byte) (int, error)
// Reset will reset the buffer
Reset()
// Bytes will return all bytes in buffer
Bytes() []byte
}
Buffer is bytes buffer interface
Click to show internal directories.
Click to hide internal directories.