callbackreader

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AfterFunc

type AfterFunc func(num int, p []byte, n int, err error) ([]byte, int, error)

AfterFunc runs after each read. num means the number of calling Read, starts from 1.

type BeforeFunc

type BeforeFunc func(num int, p []byte) []byte

BeforeFunc runs before each Read. num means the number of calling Read, starts from 1.

type CallbackReader

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

CallbackReader is counter for io.Reader

func New

func New(r io.Reader) *CallbackReader

New creates CallbackReader.

func (*CallbackReader) Close

func (cr *CallbackReader) Close() error

Close wraps Close if existed

func (*CallbackReader) OnAfter

func (cr *CallbackReader) OnAfter(fn AfterFunc)

OnAfter registers callback function running after the last read.

func (*CallbackReader) OnBefore

func (cr *CallbackReader) OnBefore(fn BeforeFunc)

OnBefore registers callback function running before the first read.

func (*CallbackReader) Read

func (cr *CallbackReader) Read(p []byte) (int, error)

Jump to

Keyboard shortcuts

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