readers

package
v2.7.3 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package readers provides several readers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AfterFunc

type AfterFunc func(total int, p []byte, err error)

AfterFunc will be called after each read.

total is the total bytes have been read.
p is the data that was read by this read.
err is the error when perform this read, could be nil or EOF.

type ByteCountReader

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

ByteCountReader wraps an io.Reader and counts the bytes read from it.

func NewByteCountReader

func NewByteCountReader(r io.Reader) *ByteCountReader

NewByteCountReader wraps an io.Reader to ByteCountReader and returns it.

func (*ByteCountReader) BytesRead

func (r *ByteCountReader) BytesRead() int

BytesRead returns the count of bytes has been read from the underlying io.Reader.

func (*ByteCountReader) Close

func (r *ByteCountReader) Close() error

Close implements io.Closer and closes the underlying io.Reader if it is an io.Closer.

func (*ByteCountReader) Error

func (r *ByteCountReader) Error() error

Error returns the error returned by the underlying io.Reader, io.EOF is treated as no error.

func (*ByteCountReader) Read

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

Read implements io.Reader.

func (*ByteCountReader) SawEOF

func (r *ByteCountReader) SawEOF() bool

SawEOF returns whether reached the EOF of the underlying io.Reader of not.

func (*ByteCountReader) SawErrorOrEOF

func (r *ByteCountReader) SawErrorOrEOF() bool

SawErrorOrEOF returns whether reached the EOF of the underlying io.Reader, or encounter an error.

type CallbackReader

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

CallbackReader wraps an io.Reader, and call the callback functions on some events.

func NewCallbackReader

func NewCallbackReader(r io.Reader) *CallbackReader

NewCallbackReader creates CallbackReader.

func (*CallbackReader) Close

func (cr *CallbackReader) Close() error

Close implements io.Closer.

func (*CallbackReader) OnAfter

func (cr *CallbackReader) OnAfter(fn AfterFunc)

OnAfter registers callback function running after the last read.

func (*CallbackReader) OnClose

func (cr *CallbackReader) OnClose(fn CloseFunc)

OnClose registers callback function running before the first read.

func (*CallbackReader) Read

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

type CloseFunc

type CloseFunc func()

CloseFunc will be called when the reader is being closed.

type GZipCompressReader

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

GZipCompressReader wraps an io.Reader to a new io.Reader, whose data is the gzip compression result of the original io.Reader.

func NewGZipCompressReader

func NewGZipCompressReader(r io.Reader) *GZipCompressReader

NewGZipCompressReader creates a new GZipCompressReader from r.

func (*GZipCompressReader) Close

func (r *GZipCompressReader) Close() error

Close implements io.Closer and closes the underlying io.Reader if it is an io.Closer.

func (*GZipCompressReader) Read

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

Read implements io.Reader.

type GZipDecompressReader

type GZipDecompressReader struct {
	*gzip.Reader
	// contains filtered or unexported fields
}

GZipDecompressReader wraps an io.Reader to a new io.Reader, whose data is the gzip decompression result of the original io.Reader.

func NewGZipDecompressReader

func NewGZipDecompressReader(r io.Reader) (*GZipDecompressReader, error)

NewGZipDecompressReader creates a new GZipDecompressReader from r.

func (*GZipDecompressReader) Close

func (r *GZipDecompressReader) Close() error

Close implements io.Closer, it closes both the gzip.Reader and the underlying io.Reader, if it is an io.Closer.

type ReaderAt

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

ReaderAt implements io.ReaderAt, io.Closer on the underlying io.Reader. Note Close of ReaderAt calls Close of the underlying io.Reader, if the io.Reader implements io.Closer.

func NewReaderAt

func NewReaderAt(r io.Reader) *ReaderAt

NewReaderAt returns a ReaderAt that reads from r.

func (*ReaderAt) Close

func (ra *ReaderAt) Close() error

Close implements io.Closer.

func (*ReaderAt) ReadAt

func (ra *ReaderAt) ReadAt(p []byte, off int64) (int, error)

ReadAt implements io.ReaderAt.

type ReaderAtReader

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

ReaderAtReader implements io.Reader on the underlying io.ReaderAt.

func NewReaderAtReader

func NewReaderAtReader(ra io.ReaderAt, off int64) *ReaderAtReader

NewReaderAtReader returns a ReaderAtReader that reads from offset off of ra.

func (*ReaderAtReader) Read

func (rar *ReaderAtReader) Read(p []byte) (int, error)

Read implements io.Reader

Jump to

Keyboard shortcuts

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