mirror of
https://github.com/restic/restic.git
synced 2025-10-09 07:33:53 +00:00
backend: move LimitReadCloser to util package
The helper is only intended for usage by backend implementations.
This commit is contained in:
15
internal/backend/util/limited_reader.go
Normal file
15
internal/backend/util/limited_reader.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package util
|
||||
|
||||
import "io"
|
||||
|
||||
// LimitedReadCloser wraps io.LimitedReader and exposes the Close() method.
|
||||
type LimitedReadCloser struct {
|
||||
io.Closer
|
||||
io.LimitedReader
|
||||
}
|
||||
|
||||
// LimitReadCloser returns a new reader wraps r in an io.LimitedReader, but also
|
||||
// exposes the Close() method.
|
||||
func LimitReadCloser(r io.ReadCloser, n int64) *LimitedReadCloser {
|
||||
return &LimitedReadCloser{Closer: r, LimitedReader: io.LimitedReader{R: r, N: n}}
|
||||
}
|
Reference in New Issue
Block a user