Documentation
¶
Overview ¶
Package sbuf implements a byte buffer that can be wiped. The underlying byte slice is wiped on read before being declaimed, and when the buffer is closed, its storage is zeroised.
Index ¶
- type Buffer
- func (buf *Buffer) Bytes() []byte
- func (buf *Buffer) Cap() int
- func (buf *Buffer) Close()
- func (buf *Buffer) Len() int
- func (buf *Buffer) Read(p []byte) (int, error)
- func (buf *Buffer) ReadByte() (byte, error)
- func (buf *Buffer) Write(p []byte) (int, error)
- func (buf *Buffer) WriteByte(c byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
A Buffer is a variable-sized buffer of bytes with Read and Write methods. The zero value for Buffer is an empty buffer ready to use.
func NewBufferFrom ¶
NewBufferFrom creates a new buffer from the byte slice passed in. The original data will be wiped.
func (*Buffer) Close ¶
func (buf *Buffer) Close()
Close destroys and zeroises the buffer. The buffer will be re-opened on the next write.
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 the next byte from the buffer. If the buffer has no data to return, err is io.EOF; otherwise it is nil.