package extraio

Import Path
	go.pact.im/x/extraio (on go.dev)

Dependency Relation
	imports 4 packages, and imported by 0 packages

Involved Source Files byte.go count.go discard.go Package extraio implements extra I/O utilities. func.go hardlimit.go hash.go pad.go tail.go unpad.go
Package-Level Type Names (total 9, all are exported)
/* sort exporteds by: | */
ByteReader is an io.Reader that reads the same byte indefinitely. Read implements the io.Reader interface. It fills p with the b byte and returns len(p). ByteReader : io.Reader
CountReader counts bytes read from the underlying io.Reader. It is implicitly limited to at most math.MaxUint64 bytes and returns ErrCounterOverflow error if the limit is exceeded. In practice, that would require counting thousands of petabytes to reach this limitation. Count returns the count of bytes read. Read implements the io.Reader interface. It reads from the underlying io.Reader and increments read bytes counter. *CountReader : io.Reader func NewCountReader(r io.Reader) *CountReader
DiscardReader is an io.Reader that discard all read bytes from the underlying reader. Note that its Read method returns zero byte count. Some io.Reader client implementations return io.ErrNoProgress error when many calls to Read have failed to return any data or error. Read implements the io.Reader interface. It reads from the underlying io.Reader but always returns zero byte count. *DiscardReader : io.Reader func NewDiscardReader(r io.Reader) *DiscardReader
HardLimitedReader reads at most n bytes from the underlying reader and returns ErrExceededReadLimit if io.EOF is not reached once the limit is exceeded. Read implements the io.Reader interface. If the limit has been reached, it returns ErrExceededReadLimit error. Otherwise it reads from the underlying io.Reader. Reset resets the reader’s state. *HardLimitedReader : io.Reader func HardLimitReader(r io.Reader, n uint64) *HardLimitedReader
HashReader wraps hash.Hash as an io.Reader. It assumes that the underlying hash state does not change after the first Read call. Hash returns the underlying hash function. Read implements the io.Reader interface. It computes the hash on the first call and advances through the hash buffer on subsequent calls to Read. Reset resets the reader’s state. It does not reset the state of the underlying hash function. *HashReader : io.Reader func NewHashReader(h hash.Hash) *HashReader
PadReader is an io.Reader that always adds non-zero padding on EOF. The the value of the padding bytes is equal to the length of the padding. Read implements the io.Reader interface. It reads from the underlying io.Reader until EOF and then writes padding into the read buffer. Reset resets the reader’s state. *PadReader : io.Reader func NewPadReader(r io.Reader, blockSize uint8) *PadReader
ReaderFunc is an adapter to allow the use of ordinary function as io.Reader. If f is a function with appropriate signature, ReaderFunc(f) is an io.Reader that calls f. Read implements the io.Reader interface. It calls f(p). ReaderFunc : io.Reader
TailReader buffers the last n bytes read from the underlying io.Reader. That is, its Read method does not return last n bytes read. Use Tail method to get the underlying buffer on EOF. Note that its Read method may return zero byte count with a nil error if read bytes fit into the underlying buffer. Some io.Reader client implementations return io.ErrNoProgress error when many calls to Read have failed to return any data or error. Length returns the length of the underlying buffer. It is faster than calling len(r.Tail()) since the underlying buffer may not be contiguous and Tail has to linearize it to return a contiguous slice of bytes. Read implements the io.Reader interface. It reads from the underlying io.Reader but keeps the last n read bytes in the internal ring buffer. Reset resets the reader’s state. Tail returns the buffer with last read bytes. The underlying buffer may not be contiguous and Tail linearizes the contents before returning a contiguous byte slice. *TailReader : io.Reader func NewTailReader(r io.Reader, n uint) *TailReader
UnpadReader is an io.Reader that unpads padding from PadReader. It validates the padding on EOF and returns an error if it is invalid. Read implements the io.Reader interface. It reads from the underlying io.Reader until EOF and then validates and removes padding from the last block. Reset resets the reader’s state. *UnpadReader : io.Reader func NewUnpadReader(r io.Reader, blockSize uint8) *UnpadReader
Package-Level Functions (total 13, in which 8 are exported)
HardLimitReader returns a Reader that reads from r but stops with an error after n bytes.
NewCountReader returns a new reader that counts bytes read from r.
NewDiscardReader returns a new reader that discard all reads from r.
NewHashReader returns a new reader that reads from the given hash function.
NewPadReader returns a new reader that pads r with the given block size. If blockSize is zero, PadReader is a no-op, i.e. it does not attempt to add padding to the underlying reader.
NewStrippedHashReader returns a new io.Reader that reads at most n bytes of the given hash function.
NewTailReader returns a new reader that buffers last n bytes read from r.
NewUnpadReader returns a new reader that unpads r using the given block size. If blockSize is zero, UnpadReader is a no-op, i.e. it does not attempt to remove padding from the underlying reader.
Package-Level Variables (total 2, both are exported)
ErrCounterOverflow is an error that CountReader returns when the counter overflows 64-bit unsigned integer.
ErrExceededReadLimit is an error that HardLimitedReader returns when it exceeds read limit.