io

package
v1.9.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package io contains utility for working with golang's io objects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeadlineReader

type DeadlineReader interface {
	io.Reader
	SetReadDeadline(time.Time) error
}

DeadlineWriter describes object that could prepare io.Reader methods with some deadline.

type DeadlineWriter

type DeadlineWriter interface {
	io.Writer
	SetWriteDeadline(time.Time) error
}

DeadlineWriter describes object that could prepare io.Writer methods with some deadline.

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

reader is a wrapper around io.Reader. Underlying reader should not be *bufio.Reader. It used to calculate stats of reading from underlying reader.

func WrapReader

func WrapReader(r io.Reader) *Reader

WrapReader wraps r into Reader to calculate usage stats of r. Note that Reader is not goroutine safe.

func (*Reader) Read

func (r *Reader) Read(p []byte) (int, error)

Read implements io.Reader interface.

func (*Reader) Stat

func (r *Reader) Stat() Stat

Stat returns underlying io.Reader usage statistics.

type Stat

type Stat struct {
	Bytes uint32 // Bytes sent/read from underlying object.
	Calls uint32 // Read/Write calls made to the underlying object.
}

Stat represents statistics about underlying io.{Reader,Writer} usage.

type TimeoutReader

type TimeoutReader struct {
	Dest    DeadlineReader
	Timeout time.Duration
}

TimeoutReader is a wrapper around DeadlineReader that sets read deadline on each Read() call. It is useful as destination for bufio.Reader, when you do not exactly know, when Read() will occure, but want to control timeout of such calls.

func (TimeoutReader) Read

func (w TimeoutReader) Read(p []byte) (int, error)

Read implements io.Reader interface.

type TimeoutWriter

type TimeoutWriter struct {
	Dest    DeadlineWriter
	Timeout time.Duration
}

TimeoutWriter is a wrapper around DeadlineWriter that sets write deadline on each Write() call. It is useful as destination for bufio.Writer, when you do not exactly know, when Write() will occure, but want to control timeout of such calls.

func (TimeoutWriter) Write

func (w TimeoutWriter) Write(p []byte) (int, error)

Write implements io.Writer interface.

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer is a wrapper around io.Writer. Underlying writer should not be *bufio.Writer. It used to calculate stats of writing to underlying writer.

func WrapWriter

func WrapWriter(w io.Writer) *Writer

WrapWriter wraps w into Writer to calculate usage stats of w. Note that Writer is not goroutine safe.

func (*Writer) Stat

func (w *Writer) Stat() Stat

Stat returns underlying io.Writer usage statistics.

func (*Writer) Write

func (w *Writer) Write(p []byte) (int, error)

Write implements io.Writer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL