Documentation
¶
Index ¶
- type Meter
- func (m *Meter) Close() error
- func (m *Meter) Count() (r, w int64)
- func (m *Meter) CountRead() int64
- func (m *Meter) CountWritten() int64
- func (m *Meter) Inc(nr, nw int64) (r, w int64)
- func (m *Meter) IncRead(n int64) int64
- func (m *Meter) IncWritten(n int64) int64
- func (m *Meter) Read(p []byte) (n int, err error)
- func (m *Meter) ReadFrom(r io.Reader) (n int64, err error)
- func (m *Meter) Write(p []byte) (n int, err error)
- func (m *Meter) WriteTo(w io.Writer) (n int64, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Meter ¶
type Meter struct {
// contains filtered or unexported fields
}
Meter records the total bytes read and written, through the underlying io.Reader and io.Writer given at construction, using any of the following interfaces:
- io.Reader (read)
- io.ReaderFrom (write)
- io.Writer (write)
- io.WriterTo (read)
Constructors also exist for read-only, write-only, and read-write Meters. Methods without an underlying interface return io.ErrClosedPipe.
[Close] will close each underlying interface that implements io.Closer.
func NewMeter ¶
NewMeter returns a new Meter that counts the total bytes read from r and written to w.
func NewReadMeter ¶
NewReadMeter returns a new Meter that counts the total bytes read from r.
func NewReadWriteMeter ¶
func NewReadWriteMeter(rw io.ReadWriter) *Meter
NewReadWriteMeter returns a new Meter that counts the total bytes read from and written to rw.
func NewWriteMeter ¶
NewWriteMeter returns a new Meter that counts the total bytes written to w.
func (*Meter) Close ¶
Close closes each underlying interface that implements io.Closer.
See io.Closer for details.
func (*Meter) CountWritten ¶
CountWritten returns the total bytes written.
func (*Meter) Inc ¶
Inc increments the total bytes read and written by nr and nw, respectively, and returns the new byte counts.
func (*Meter) IncRead ¶
IncRead increments the total bytes read by n and returns the new byte count.
func (*Meter) IncWritten ¶
IncWritten increments the total bytes written by n and returns the new byte count.
func (*Meter) Read ¶
Read writes the underlying io.Reader to p and increments the total bytes read by n.
See io.Reader for details.
func (*Meter) ReadFrom ¶
ReadFrom copies from r to the underlying io.Writer and increments the total bytes written by n.
See io.ReaderFrom for details.