Documentation ¶
Overview ¶
Package counter implements counting readers and writers
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CountCallback ¶
type CountCallback func(count int64)
A CountCallback is called whenever some data is written or read and the byte count changes
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
A Reader keeps track of how many bytes have been read from a reader
func NewReader ¶
NewReader returns a new counting reader. If the specified reader is nil, it will still count all bytes written, then discard them
func NewReaderCallback ¶
func NewReaderCallback(onRead CountCallback, reader io.Reader) *Reader
NewReaderCallback returns a new counting reader with a callback to be called on every read.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
A Writer keeps track of how many bytes have been written to a writer
func NewWriter ¶
NewWriter returns a new counting writer. If the specified writer is nil, it will still count all bytes written, then discard them
func NewWriterCallback ¶
func NewWriterCallback(onWrite CountCallback, writer io.Writer) *Writer
NewWriterCallback returns a new counting writer with a callback to be called on every write.