part

package
v0.28.20240501130702 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 7 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWrite = errors.New("ErrWrite")
	ErrRead  = errors.New("ErrRead")
)

Functions

func Copy added in v0.28.1

func Copy(r io.Reader, w io.Writer, c CopyConfig) (e error)

close by yourself

watch out uint64(c.MaxLoop*c.BytePerLoop) overflow

func RW2Chan

func RW2Chan(r io.ReadCloser, w io.WriteCloser) (rc, wc chan []byte)

no close rc any time you can close wc, r, w.

func WithCtxCopy added in v0.28.1

func WithCtxCopy(ctx context.Context, callTree string, copybuf []byte, to time.Duration, w io.Writer, r io.Reader, panicf ...func(s string)) error

close reader by yourself

to avoid writer block after ctx done, you should close writer after ctx done

call Close() after writer fin

func WithCtxTO added in v0.28.1

func WithCtxTO(ctx context.Context, callTree string, to time.Duration, w io.Writer, r io.Reader, panicf ...func(s string)) io.ReadWriteCloser

close reader by yourself

to avoid writer block after ctx done, you should close writer after ctx done

call Close() after writer fin

Types

type CopyConfig added in v0.28.1

type CopyConfig struct {
	BytePerLoop, MaxLoop, MaxByte, BytePerSec uint64
}

type IOpipe added in v0.28.1

type IOpipe struct {
	R *io.PipeReader
	W *io.PipeWriter
	// contains filtered or unexported fields
}

func NewPipe added in v0.28.1

func NewPipe() *IOpipe

func (*IOpipe) Close added in v0.28.1

func (t *IOpipe) Close() (err error)

func (*IOpipe) CloseWithError added in v0.28.1

func (t *IOpipe) CloseWithError(e error) (err error)

func (*IOpipe) Read added in v0.28.1

func (t *IOpipe) Read(p []byte) (n int, err error)

func (*IOpipe) Write added in v0.28.1

func (t *IOpipe) Write(p []byte) (n int, err error)

type RWC added in v0.28.1

type RWC struct {
	R func(p []byte) (n int, err error)
	W func(p []byte) (n int, err error)
	C func() error
}

func (RWC) Close added in v0.28.1

func (t RWC) Close() error

func (RWC) Read added in v0.28.1

func (t RWC) Read(p []byte) (n int, err error)

func (RWC) Write added in v0.28.1

func (t RWC) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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