Documentation ¶
Index ¶
- func NewContextReader(ctx context.Context, r io.Reader) io.Reader
- func NewLimitedReadCloser(rc io.ReadCloser, limit int64) (lrc io.ReadCloser)
- func NewPatternReader(length int64) io.ReadSeeker
- func NoCloser(in io.Reader) io.Reader
- func ReadFill(r io.Reader, buf []byte) (n int, err error)
- type CountingReader
- type ErrorReader
- type LimitedReadCloser
- type RepeatableReader
- func NewRepeatableLimitReader(r io.Reader, size int) *RepeatableReader
- func NewRepeatableLimitReaderBuffer(r io.Reader, buf []byte, size int64) *RepeatableReader
- func NewRepeatableReader(r io.Reader) *RepeatableReader
- func NewRepeatableReaderBuffer(r io.Reader, buf []byte) *RepeatableReader
- func NewRepeatableReaderSized(r io.Reader, size int) *RepeatableReader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewContextReader ¶ added in v1.55.0
NewContextReader creates a reader, that returns any errors that ctx gives
func NewLimitedReadCloser ¶
func NewLimitedReadCloser(rc io.ReadCloser, limit int64) (lrc io.ReadCloser)
NewLimitedReadCloser returns a LimitedReadCloser wrapping rc to limit it to reading limit bytes. If limit < 0 then it does not wrap rc, it just returns it.
func NewPatternReader ¶
func NewPatternReader(length int64) io.ReadSeeker
NewPatternReader creates a reader, that returns a deterministic byte pattern. After length bytes are read
Types ¶
type CountingReader ¶
type CountingReader struct {
// contains filtered or unexported fields
}
CountingReader holds a reader and a read count of how many bytes were read so far.
func NewCountingReader ¶
func NewCountingReader(in io.Reader) *CountingReader
NewCountingReader returns a CountingReader, which will read from the given reader while keeping track of how many bytes were read.
func (*CountingReader) BytesRead ¶
func (cr *CountingReader) BytesRead() uint64
BytesRead returns how many bytes were read from the underlying reader so far.
type ErrorReader ¶ added in v1.52.0
type ErrorReader struct {
Err error
}
ErrorReader wraps an error to return on Read
type LimitedReadCloser ¶
type LimitedReadCloser struct { *io.LimitedReader io.Closer }
LimitedReadCloser adds io.Closer to io.LimitedReader. Create one with NewLimitedReadCloser
type RepeatableReader ¶
type RepeatableReader struct {
// contains filtered or unexported fields
}
A RepeatableReader implements the io.ReadSeeker it allow to seek cached data back and forth within the reader but will only read data from the internal Reader as necessary and will play nicely with the Account and io.LimitedReader to reflect current speed
func NewRepeatableLimitReader ¶
func NewRepeatableLimitReader(r io.Reader, size int) *RepeatableReader
NewRepeatableLimitReader create new repeatable reader from Reader r with an initial buffer of size wrapped in an io.LimitReader to read only size.
func NewRepeatableLimitReaderBuffer ¶
func NewRepeatableLimitReaderBuffer(r io.Reader, buf []byte, size int64) *RepeatableReader
NewRepeatableLimitReaderBuffer create new repeatable reader from Reader r and buf wrapped in an io.LimitReader to read only size.
func NewRepeatableReader ¶
func NewRepeatableReader(r io.Reader) *RepeatableReader
NewRepeatableReader create new repeatable reader from Reader r
func NewRepeatableReaderBuffer ¶
func NewRepeatableReaderBuffer(r io.Reader, buf []byte) *RepeatableReader
NewRepeatableReaderBuffer create new repeatable reader from Reader r using the buffer passed in.
func NewRepeatableReaderSized ¶
func NewRepeatableReaderSized(r io.Reader, size int) *RepeatableReader
NewRepeatableReaderSized create new repeatable reader from Reader r with an initial buffer of size.
func (*RepeatableReader) Read ¶
func (r *RepeatableReader) Read(b []byte) (n int, err error)
Read data from original Reader into bytes Data is either served from the underlying Reader or from cache if was already read
func (*RepeatableReader) Seek ¶
func (r *RepeatableReader) Seek(offset int64, whence int) (int64, error)
Seek implements the io.Seeker interface. If seek position is passed the cache buffer length the function will return the maximum offset that can be used and "fs.RepeatableReader.Seek: offset is unavailable" Error