iotools

package module
v0.0.0-...-934ae9c Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 License: MIT Imports: 1 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AtEOF

func AtEOF(r io.Reader) bool

AtEOF returns true when reader at EOF, this is checked with a 0 length read.

func CloseOnce

func CloseOnce(c io.Closer) io.Closer

CloseOnce wraps an io.Closer to ensure it only performs the close logic once.

func CloserAfterCallback

func CloserAfterCallback(c io.Closer, cb func()) io.Closer

CloserAfterCallback wraps io.Closer to add a callback called just before Close().

func CloserCallback

func CloserCallback(c io.Closer, cb func()) io.Closer

CloserCallback wraps io.Closer to add a callback deferred to call just after Close().

func GetReadCloserLimit

func GetReadCloserLimit(rc io.ReadCloser) (*io.LimitedReader, int64)

GetReadCloserLimit attempts to unwrap io.ReadCloser to access its io.LimitedReader with limit.

func GetReaderLimit

func GetReaderLimit(r io.Reader) (*io.LimitedReader, int64)

GetReadCloserLimit attempts to cast io.Reader to access its io.LimitedReader with limit.

func NopReadCloser

func NopReadCloser(r io.Reader) io.ReadCloser

NopReadCloser wraps io.Reader with NopCloser{} in ReadCloserType.

func NopWriteCloser

func NopWriteCloser(w io.Writer) io.WriteCloser

NopWriteCloser wraps an io.Writer to implement io.WriteCloser with empty io.Closer implementation.

func ReadCloser

func ReadCloser(r io.Reader, c io.Closer) io.ReadCloser

ReadCloser wraps an io.Reader and io.Closer in order to implement io.ReadCloser.

func UpdateReadCloserLimit

func UpdateReadCloserLimit(rc io.ReadCloser, limit int64) (io.ReadCloser, *io.LimitedReader, int64)

UpdateReadCloserLimit attempts to update the limit of a readcloser for existing, newly wrapping if necessary.

func UpdateReaderLimit

func UpdateReaderLimit(r io.Reader, limit int64) (*io.LimitedReader, int64)

UpdateReaderLimit attempts to update the limit of a reader for existing, newly wrapping if necessary.

func WriteCloser

func WriteCloser(w io.Writer, c io.Closer) io.WriteCloser

WriteCloser wraps an io.Writer and io.Closer in order to implement io.WriteCloser.

Types

type CloserFunc

type CloserFunc func() error

CloserFunc is a function signature which allows a function to implement the io.Closer type.

func (CloserFunc) Close

func (c CloserFunc) Close() error

type LengthFunc

type LengthFunc func() int

LengthFunc is a function signature which allows a function to implement the Lengther type.

func (LengthFunc) Len

func (l LengthFunc) Len() int

type Lengther

type Lengther interface {
	Len() int
}

type NopCloser

type NopCloser struct{}

NopCloser is an empty implementation of io.Closer, that simply does nothing!

func (NopCloser) Close

func (NopCloser) Close() error

type ReadCloserType

type ReadCloserType struct {
	io.Reader
	io.Closer
}

ReadCloserType implements io.ReadCloser by combining the two underlying interfaces, while providing an exported type to still access the underlying original io.Reader or io.Closer separately (e.g. without wrapping).

type ReaderFromFunc

type ReaderFromFunc func(io.Reader) (int64, error)

ReaderFromFunc is a function signature which allows a function to implement the io.ReaderFrom type.

func (ReaderFromFunc) ReadFrom

func (rf ReaderFromFunc) ReadFrom(r io.Reader) (int64, error)

type ReaderFunc

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

ReaderFunc is a function signature which allows a function to implement the io.Reader type.

func (ReaderFunc) Read

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

type Sizer

type Sizer interface {
	Size() int64
}

type SizerFunc

type SizerFunc func() int64

SizerFunc is a function signature which allows a function to implement the Sizer type.

func (SizerFunc) Size

func (s SizerFunc) Size() int64

type WriterFunc

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

WriterFunc is a function signature which allows a function to implement the io.Writer type.

func (WriterFunc) Write

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

type WriterToFunc

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

WriterToFunc is a function signature which allows a function to implement the io.WriterTo type.

func (WriterToFunc) WriteTo

func (wt WriterToFunc) WriteTo(r io.Writer) (int64, error)

Jump to

Keyboard shortcuts

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