gio

package
v0.0.0-...-2bcc11b Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: GPL-3.0 Imports: 10 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 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 Read

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

Read is based on standard io library.

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 ReadFrom

func ReadFrom(dst *bytes.Buffer, src io.Reader, timeout *time.Duration) (n int64, err error)

ReadFrom is based on standard io library.

func ReadFull

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

ReadFull reads from r into buf, until exactly len(buf) bytes read, or error returned, including gerrors.ErrTimeout, io.EOF, io.ErrUnexpectedEOF, and any other type of error.

func ReadHead

func ReadHead(r io.Reader, timeout *time.Duration) (*bytes.Buffer, error)

ReadHead try best to Read until n==0 or error is returned.

func ReadLine

func ReadLine(r io.Reader, keepN bool, maxSize int) ([]byte, error)

ReadLine reads from r into buf, until '\n' read, or maxSize read, or error returned, including io.EOF, io.ErrUnexpectedEOF, and any other type of error. Note: this function is slow, DO NOT call this function too often!

func ReadUntil

func ReadUntil(r io.Reader, delim byte, keepDelim bool, maxSize int) ([]byte, error)

ReadUntil reads until the first occurrence of delim in the input, or maxSize read, or error returned, including io.EOF, io.ErrUnexpectedEOF, and any other type of error. Note: this function is slow, DO NOT call this function too often!

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 TwoWaysCopy

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

Types

type BufEx

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

func NewBufEx

func NewBufEx(r io.Reader) *BufEx

func (*BufEx) Read

func (r *BufEx) Read(b []byte) (n int, err error)

func (*BufEx) SetReadTimeout

func (r *BufEx) SetReadTimeout(t time.Duration) time.Duration

SetReadTimeout sets the timeout for all future Read calls as follows:

 t:
	t<0:  block
	t==0: poll
	t>0:  timeout after t

type CopiedSizeCallback

type CopiedSizeCallback func(size int64)

type ErrNotify

type ErrNotify func(err error)

type Flusher

type Flusher interface {
	Flush() error
}

type NormalReader

type NormalReader SniffBuf // normal reader which isn't rewindable

func (*NormalReader) Read

func (sc *NormalReader) Read(p []byte) (n int, err error)

Normal(not rewindable) io.Read()

type ReaderTimeout

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

type RewindReader

type RewindReader SniffBuf // special reader which is rewindable

func (*RewindReader) Read

func (sc *RewindReader) Read(p []byte) (n int, err error)

Rewindable io.Read()

func (*RewindReader) Rewind

func (sc *RewindReader) Rewind()

Rewind resets offset to 0.

type SetDeadlineCallback

type SetDeadlineCallback func(t time.Time) error

type SniffBuf

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

func NewSniffBuf

func NewSniffBuf(src io.Reader) *SniffBuf

NewSniffBuf creates a new SniffBuff

func (*SniffBuf) NormalReader

func (sc *SniffBuf) NormalReader() *NormalReader

NormalReader exports a normal io.Reader

func (*SniffBuf) RewindReader

func (sc *SniffBuf) RewindReader() *RewindReader

RewindReader exports a RewindReader

type TimeoutR

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

type TimeoutReadCloser

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

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
}

type TimeoutWriteCloser

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

type WriteFlushCloser

type WriteFlushCloser interface {
	io.Writer
	Flusher
	io.Closer
}

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