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 ¶
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) 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.
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.
type GZipDecompressReader ¶
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 ¶
NewReaderAt returns a ReaderAt that reads from r.
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.