Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrFull = errors.New("full buffer")
ErrFull is returned when the buffer has hit the configured limits.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer allows writing packets to an intermediate buffer, which can then be read form. This is verify similar to bytes.Buffer but avoids combining multiple writes into a single read.
func (*Buffer) Close ¶
Close will unblock any readers and prevent future writes. Data in the buffer can still be read, returning io.EOF when fully depleted.
func (*Buffer) Read ¶
Read populates the given byte slice, returning the number of bytes read. Blocks until data is available or the buffer is closed. Returns io.ErrShortBuffer is the packet is too small to copy the Write. Returns io.EOF if the buffer is closed.
func (*Buffer) SetLimitCount ¶
SetLimitCount controls the maximum number of packets that can be buffered. Causes Write to return ErrFull when this limit is reached. A zero value will disable this limit.
func (*Buffer) SetLimitSize ¶
SetLimitSize controls the maximum number of bytes that can be buffered. Causes Write to return ErrFull when this limit is reached. A zero value will disable this limit.