gio

package
v0.0.0-...-04ff805 Latest Latest
Warning

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

Go to latest
Published: May 22, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToReadCloser

func BytesToReadCloser(b []byte) io.ReadCloser

func CopyBuffer

func CopyBuffer(dst io.Writer, src io.Reader, buf []byte) (written int64, err error)

https://github.com/xtaci/kcptun/blob/master/server/main.go io.CopyBuffer has extra tests for interface like io.ReaderFrom and io.WriterTo which is not efficient in memory management from tests

func CopyEx

func CopyEx(dst io.Writer, dstWriteCb SetDeadlineCallback, src io.Reader, srcReadCb SetDeadlineCallback, timeout time.Duration, sizeCallback CopiedSizeCallback) (written int64, err error)

https://github.com/efarrer/iothrottler/ https://github.com/jwkohnen/bwio/ limit copy speed / duration, read copied size

func CopyTimeout

func CopyTimeout(dst io.Writer, src io.Reader, noDataTimeout time.Duration) (written int64, err error)

CopyTimeout is a Copy function with no data timeout parameter. Note: among the two, 'dst' and 'src', there must be at least one net.Conn More: https://groups.google.com/g/golang-nuts/c/byfD0YtIl0I

func ReadAtLeast

func ReadAtLeast(r io.Reader, buf []byte, min int, timeout *time.Duration) (n int, err error)

ReadAtLeast is based on standard io library.

func ReadCloserToBytes

func ReadCloserToBytes(rd io.ReadCloser) ([]byte, error)

func ReadCloserToInterface

func ReadCloserToInterface(rd io.ReadCloser) (interface{}, error)

func ReadCloserToString

func ReadCloserToString(rd io.ReadCloser) (string, error)

func ReadFull

func ReadFull(r io.Reader, buf []byte, timeout *time.Duration) (n int, err error)

ReadFull is based on standard io library.

func ReaderToBytes

func ReaderToBytes(rd io.Reader) ([]byte, error)

func ReaderToString

func ReaderToString(rd io.Reader) (string, error)

func StringToReadCloser

func StringToReadCloser(s string) io.ReadCloser

func TwoWayCopy

func TwoWayCopy(s1, s2 io.ReadWriteCloser, errNotify ErrNotify)

Types

type CopiedSizeCallback

type CopiedSizeCallback func(size int64)

type ErrNotify

type ErrNotify func(err error)

type Flusher

type Flusher interface {
	Flush() error
}

type SetDeadlineCallback

type SetDeadlineCallback func(t time.Time) error

type TimeoutR

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

func (*TimeoutR) Close

func (r *TimeoutR) Close() error

func (*TimeoutR) Read

func (r *TimeoutR) Read(p []byte) (n int, err error)

func (*TimeoutR) SetReadDeadline

func (r *TimeoutR) SetReadDeadline(t time.Time) error

type TimeoutReadCloser

type TimeoutReadCloser interface {
	io.ReadCloser
	SetReadDeadline(t time.Time) error
}

func WrapTimeoutReader

func WrapTimeoutReader(r io.ReadCloser) TimeoutReadCloser

type TimeoutReadWriteCloser

type TimeoutReadWriteCloser interface {
	io.ReadWriteCloser
	SetReadDeadline(t time.Time) error
	SetWriteDeadline(t time.Time) error
	SetDeadline(t time.Time) error
}

type TimeoutW

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

func (*TimeoutW) Close

func (w *TimeoutW) Close() error

func (*TimeoutW) SetWriteDeadline

func (w *TimeoutW) SetWriteDeadline(t time.Time) error

func (*TimeoutW) Write

func (w *TimeoutW) Write(p []byte) (n int, err error)

type TimeoutWriteCloser

type TimeoutWriteCloser interface {
	io.WriteCloser
	SetWriteDeadline(t time.Time) error
}

func WrapTimeoutWriter

func WrapTimeoutWriter(w io.WriteCloser) TimeoutWriteCloser

type WriteFlusher

type WriteFlusher interface {
	io.Writer
	Flusher
}

Jump to

Keyboard shortcuts

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