uio

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2018 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLazyOpener

func NewLazyOpener(open func() (io.Reader, error)) io.ReadCloser

NewLazyOpener returns a lazy io.Reader based on `open`.

func ReadAll

func ReadAll(r io.ReaderAt) ([]byte, error)

ReadAll reads everything that r contains.

Callers *must* not modify bytes in the returned byte slice.

If r is an in-memory representation, ReadAll will attempt to return a pointer to those bytes directly.

func Reader

func Reader(r io.ReaderAt) io.Reader

Reader generates a Reader from a ReaderAt.

Types

type CachingReader

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

CachingReader is a lazily caching wrapper of an io.Reader.

The wrapped io.Reader is only read from on demand, not upfront.

func NewCachingReader

func NewCachingReader(r io.Reader) *CachingReader

NewCachingReader buffers reads from r.

r is only read from when Read() is called.

func (*CachingReader) NewReader

func (cr *CachingReader) NewReader() io.Reader

NewReader returns a new io.Reader that reads cr from offset 0.

func (*CachingReader) Read

func (cr *CachingReader) Read(p []byte) (int, error)

Read reads from cr; implementing io.Reader.

TODO(chrisko): Decide whether to keep this or only keep NewReader().

func (*CachingReader) ReadAt

func (cr *CachingReader) ReadAt(p []byte, off int64) (int, error)

ReadAt reads from cr; implementing io.ReaderAt.

type LazyOpener

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

LazyOpener is a lazy io.Reader.

LazyOpener will use a given open function to derive an io.Reader when Read is first called on the LazyOpener.

func (*LazyOpener) Close

func (lr *LazyOpener) Close() error

Close implements io.Closer.Close.

func (*LazyOpener) Read

func (lr *LazyOpener) Read(p []byte) (int, error)

Read implements io.Reader.Read lazily.

If called for the first time, the underlying reader will be obtained and then used for the first and subsequent calls to Read.

type LazyOpenerAt

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

LazyOpenerAt is a lazy io.ReaderAt.

LazyOpenerAt will use a given open function to derive an io.ReaderAt when ReadAt is first called.

func (*LazyOpenerAt) Close

func (loa *LazyOpenerAt) Close() error

Close implements io.Closer.Close.

func (*LazyOpenerAt) ReadAt

func (loa *LazyOpenerAt) ReadAt(p []byte, off int64) (int, error)

ReadAt implements io.ReaderAt.ReadAt.

type ReadAtCloser

type ReadAtCloser interface {
	io.ReaderAt
	io.Closer
}

ReadAtCloser is an io.ReaderAt and an io.Closer.

func NewLazyOpenerAt

func NewLazyOpenerAt(open func() (io.ReaderAt, error)) ReadAtCloser

NewLazyOpenerAt returns a lazy io.ReaderAt based on `open`.

Jump to

Keyboard shortcuts

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