Documentation ¶
Overview ¶
Package lifobuffer implements bytes buffer with LIFO order (last-in-first-out)
Index ¶
- Variables
- type Buffer
- func (b *Buffer) Len() int
- func (b *Buffer) Next(n int) (p []byte)
- func (b *Buffer) Read(p []byte) (n int, err error)
- func (b *Buffer) ReadByte() (c byte, err error)
- func (b *Buffer) Write(p []byte) (n int, err error)
- func (b *Buffer) WriteByte(c byte) (err error)
- func (b *Buffer) WriteTo(w io.Writer) (n int64, err error)
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidWriteCount = errors.New("lifo.Buffer.WriteTo:" +
" invalid Write count")
ErrInvalidWriteCount is returned when WriteTo's writer returns wrong count
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer []byte
Buffer is LIFO bytes buffer type
func (*Buffer) Next ¶
Next returns a slice containing the next n bytes from the buffer, advancing the buffer as if the bytes had been returned by Read. If there are fewer than n bytes in the buffer, Next returns the entire buffer.
func (*Buffer) Read ¶
Read reads the next len(p) bytes from the buffer or until the buffer is drained. The return value n is the number of bytes read. If the buffer has no data to return, err is io.EOF (unless len(p) is zero); otherwise it is nil.
func (*Buffer) ReadByte ¶
ReadByte reads and returns the next byte from the buffer. If no byte is available, it returns error io.EOF.
func (*Buffer) Write ¶
Write appends the contents of p to the buffer, growing the buffer as needed. The return value n is the length of p. The err will be always nil
func (*Buffer) WriteByte ¶
WriteByte appends the byte c to the buffer, growing the buffer as needed. It always returns nil
func (*Buffer) WriteTo ¶
WriteTo writes data to w until the buffer is drained or an error occurs. The return value n is the number of bytes written; it always fits into an int, but it is int64 to match the io.WriterTo interface. Any error encountered during the write is also returned. If w returns invalid count err will be ErrInvalidWriteCount