rclone: github.com/ncw/rclone/lib/readers Index | Files

package readers

import "github.com/ncw/rclone/lib/readers"


Package Files

counting_reader.go error.go limited.go noclose.go pattern_reader.go readfill.go repeatable.go

func NewLimitedReadCloser Uses

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 Uses

func NewPatternReader(length int64) io.ReadSeeker

NewPatternReader creates a reader, that returns a deterministic byte pattern. After length bytes are read

func NoCloser Uses

func NoCloser(in io.Reader) io.Reader

NoCloser makes sure that the io.Reader passed in can't upgraded to an io.Closer.

This is for use with http.NewRequest to make sure the body doesn't get upgraded to an io.Closer and the body closed unexpectedly.

func ReadFill Uses

func ReadFill(r io.Reader, buf []byte) (n int, err error)

ReadFill reads as much data from r into buf as it can

It reads until the buffer is full or r.Read returned an error.

This is io.ReadFull but when you just want as much data as possible, not an exact size of block.

type CountingReader Uses

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 Uses

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 Uses

func (cr *CountingReader) BytesRead() uint64

BytesRead returns how many bytes were read from the underlying reader so far.

func (*CountingReader) Read Uses

func (cr *CountingReader) Read(b []byte) (int, error)

Read reads from the underlying reader.

type ErrorReader Uses

type ErrorReader struct {
    Err error

ErrorReader wraps an error to return on Read

func (ErrorReader) Read Uses

func (er ErrorReader) Read(p []byte) (n int, err error)

Read always returns the error

type LimitedReadCloser Uses

type LimitedReadCloser struct {

LimitedReadCloser adds io.Closer to io.LimitedReader. Create one with NewLimitedReadCloser

type RepeatableReader Uses

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 Uses

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 Uses

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 Uses

func NewRepeatableReader(r io.Reader) *RepeatableReader

NewRepeatableReader create new repeatable reader from Reader r

func NewRepeatableReaderBuffer Uses

func NewRepeatableReaderBuffer(r io.Reader, buf []byte) *RepeatableReader

NewRepeatableReaderBuffer create new repeatable reader from Reader r using the buffer passed in.

func NewRepeatableReaderSized Uses

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 Uses

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 Uses

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

Package readers imports 3 packages (graph) and is imported by 25 packages. Updated 2020-07-07. Refresh now. Tools for package owners.