Documentation ¶
Index ¶
- Variables
- type Buffer
- func (b *Buffer) CapDelta() int
- func (b *Buffer) CommitTail(n int)
- func (b *Buffer) Get() []byte
- func (b *Buffer) GetPos() (int64, int64)
- func (b *Buffer) Index(i int64) int
- func (b *Buffer) Read(n int) (p []byte, err error)
- func (b *Buffer) Set(p []byte, start, end int) error
- func (b *Buffer) SetPos(tail, head int64)
- func (b *Buffer) Stop()
- type BytesPool
- type Reader
- type Writer
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct { Mu sync.RWMutex // the buffer needs it's own mutex to work properly. ID string // the identifier of the buffer. This is used in debug output. State int64 // indicates whether the buffer is reading from (1) or writing to (2). // contains filtered or unexported fields }
buffer contains core values and methods to be included in a reader or writer.
func NewBuffer ¶
NewBuffer returns a new instance of buffer. You should call NewReader or NewWriter instead of this function.
func NewBufferFromSlice ¶
NewBufferFromSlice returns a new instance of buffer using a pre-existing byte slice.
func (*Buffer) CommitTail ¶
CommitTail moves the tail position of the buffer n bytes.
func (*Buffer) GetPos ¶
Get will return the tail and head positions of the buffer. This method is for use with testing.
func (*Buffer) Read ¶
Read reads n bytes from the buffer, and will block until at n bytes exist in the buffer to read.
type BytesPool ¶
type BytesPool struct {
// contains filtered or unexported fields
}
BytesPool is a pool of []byte.
type Reader ¶
type Reader struct {
Buffer
}
Reader is a circular buffer for reading data from an io.Reader.
func NewReaderFromSlice ¶
NewReaderFromSlice returns a new Circular Reader using a pre-exising byte slice.
type Writer ¶
type Writer struct {
Buffer
}
Writer is a circular buffer for writing data to an io.Writer.
func NewWriterFromSlice ¶
NewWriterFromSlice returns a new Circular Writer using a pre-exising byte slice.