iokit

package
v0.0.0-...-05bc493 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LimitOfReader

func LimitOfReader(r io.Reader) int64

func LimitOfWriter

func LimitOfWriter(w io.Writer) int64

func LimitOfWriterTo

func LimitOfWriterTo(w io.WriterTo) int64

func NewTeeReader

func NewTeeReader(main io.Reader, copy io.Writer) io.Reader

func NewTeeReaderWithSkip

func NewTeeReaderWithSkip(main io.Reader, copy io.Writer, skipLeadingBytes int) io.Reader

func NewTeeWriter

func NewTeeWriter(main, copy io.Writer) io.Writer

func NewTeeWriterWithSkip

func NewTeeWriterWithSkip(main, copy io.Writer, zeroLeadingBytes int) io.Writer

func RateLimitedBySize

func RateLimitedBySize(n int64, q RateLimiter) error

func RateLimitedByteCopy

func RateLimitedByteCopy(fn func([]byte) (int, error), p []byte, q RateLimiter) (int, error)

func RateLimitedCopy

func RateLimitedCopy(writer io.Writer, reader io.Reader, q RateLimiter) (int64, error)

func SafeClose

func SafeClose(c io.Closer) error

func SafeCloseChain

func SafeCloseChain(c io.Closer, prev error) error

func SafeCloseWithDefault

func SafeCloseWithDefault(c io.Closer, nilErrorFn func() error) error

func WriteZeros

func WriteZeros(x int, w io.Writer) (int, error)

Types

type ErrorWrapper

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

func WrapError

func WrapError(err error) ErrorWrapper

func (ErrorWrapper) Close

func (w ErrorWrapper) Close() error

func (ErrorWrapper) Error

func (w ErrorWrapper) Error() error

func (ErrorWrapper) Len

func (w ErrorWrapper) Len() int

func (ErrorWrapper) Read

func (w ErrorWrapper) Read(p []byte) (n int, err error)

func (ErrorWrapper) Seek

func (w ErrorWrapper) Seek(offset int64, whence int) (int64, error)

func (ErrorWrapper) Write

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

type LenReader

type LenReader interface {
	io.Reader
	Len() int
}

type LimitedReader

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

func LimitReader

func LimitReader(r io.Reader, n int64) *LimitedReader

func NewLimitedTeeReader

func NewLimitedTeeReader(main io.Reader, copy io.Writer, limit int64) *LimitedReader

func NewLimitedTeeReaderWithSkip

func NewLimitedTeeReaderWithSkip(main io.Reader, copy io.Writer, skipLeadingBytes int, limit int64) *LimitedReader

func (*LimitedReader) Len

func (l *LimitedReader) Len() int

func (*LimitedReader) Read

func (l *LimitedReader) Read(p []byte) (n int, err error)

func (*LimitedReader) RemainingBytes

func (l *LimitedReader) RemainingBytes() int64

type LimitedTriggerReader

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

func LimitReaderWithTrigger

func LimitReaderWithTrigger(r io.Reader, n int64, triggerFn func(int64)) *LimitedTriggerReader

func (*LimitedTriggerReader) Close

func (p *LimitedTriggerReader) Close() error

func (*LimitedTriggerReader) Read

func (p *LimitedTriggerReader) Read(b []byte) (int, error)

type LimitedWriter

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

func LimitWriter

func LimitWriter(w io.Writer, n int64) *LimitedWriter

func NewLimitedTeeWriter

func NewLimitedTeeWriter(main, copy io.Writer, limit int64) *LimitedWriter

func NewLimitedTeeWriterWithSkip

func NewLimitedTeeWriterWithSkip(main, copy io.Writer, skipLeadingBytes int, limit int64) *LimitedWriter

func (*LimitedWriter) RemainingBytes

func (l *LimitedWriter) RemainingBytes() int64

func (*LimitedWriter) Write

func (l *LimitedWriter) Write(p []byte) (n int, err error)

type NullReadWriter

type NullReadWriter struct{}

func Null

func Null() NullReadWriter

func (NullReadWriter) Read

func (p NullReadWriter) Read(b []byte) (int, error)

func (NullReadWriter) Write

func (p NullReadWriter) Write(b []byte) (int, error)

type PrependedReader

type PrependedReader struct {
	R io.Reader
	// contains filtered or unexported fields
}

func PrependReader

func PrependReader(b []byte, r io.Reader) *PrependedReader

func (*PrependedReader) Read

func (p *PrependedReader) Read(b []byte) (int, error)

type PrependedWriter

type PrependedWriter struct {
	W io.Writer
	// contains filtered or unexported fields
}

func PrependWriter

func PrependWriter(b []byte, w io.Writer) *PrependedWriter

func (*PrependedWriter) Close

func (p *PrependedWriter) Close() error

func (*PrependedWriter) Flush

func (p *PrependedWriter) Flush() error

func (*PrependedWriter) Write

func (p *PrependedWriter) Write(b []byte) (int, error)

type RateLimitedReader

type RateLimitedReader struct {
	R io.Reader
	Q RateLimiter
}

func RateLimitReader

func RateLimitReader(r io.Reader, q RateLimiter) *RateLimitedReader

func (RateLimitedReader) Close

func (r RateLimitedReader) Close() error

func (RateLimitedReader) Read

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

func (RateLimitedReader) WriteTo

func (r RateLimitedReader) WriteTo(w io.Writer) (int64, error)

type RateLimitedWriter

type RateLimitedWriter struct {
	W io.Writer
	Q RateLimiter
}

func RateLimitWriter

func RateLimitWriter(w io.Writer, q RateLimiter) *RateLimitedWriter

func (RateLimitedWriter) Close

func (r RateLimitedWriter) Close() error

func (RateLimitedWriter) ReadFrom

func (r RateLimitedWriter) ReadFrom(rd io.Reader) (int64, error)

func (RateLimitedWriter) Write

func (r RateLimitedWriter) Write(p []byte) (int, error)

type RateLimiter

type RateLimiter interface {
	TakeQuota(max int64) int64
}

type ReaderFunc

type ReaderFunc func([]byte) (int, error)

func (ReaderFunc) Read

func (v ReaderFunc) Read(b []byte) (int, error)

type TeeReader

type TeeReader struct {
	R io.Reader
	// contains filtered or unexported fields
}

func (*TeeReader) Read

func (w *TeeReader) Read(b []byte) (n int, err error)

type TeeWriter

type TeeWriter struct {
	W io.Writer
	// contains filtered or unexported fields
}

func (*TeeWriter) Write

func (w *TeeWriter) Write(b []byte) (n int, err error)

type WriterFunc

type WriterFunc func([]byte) (int, error)

func (WriterFunc) Write

func (v WriterFunc) Write(b []byte) (int, error)

type WriterToFunc

type WriterToFunc func(io.Writer) (int64, error)

func (WriterToFunc) WriteTo

func (v WriterToFunc) WriteTo(w io.Writer) (int64, error)

Jump to

Keyboard shortcuts

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