Files
diun/vendor/go.podman.io/storage/pkg/ioutils/writers.go
dependabot[bot] e656c2082a chore(deps): bump go.podman.io/image/v5 from 5.37.0 to 5.38.0
Bumps [go.podman.io/image/v5](https://github.com/containers/container-libs) from 5.37.0 to 5.38.0.
- [Commits](https://github.com/containers/container-libs/compare/image/v5.37.0...image/v5.38.0)

---
updated-dependencies:
- dependency-name: go.podman.io/image/v5
  dependency-version: 5.38.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-10 07:01:50 +00:00

67 lines
1.4 KiB
Go

package ioutils
import "io"
// NopWriter represents a type which write operation is nop.
type NopWriter struct{}
func (*NopWriter) Write(buf []byte) (int, error) {
return len(buf), nil
}
type nopWriteCloser struct {
io.Writer
}
func (w *nopWriteCloser) Close() error { return nil }
// NopWriteCloser returns a nopWriteCloser.
func NopWriteCloser(w io.Writer) io.WriteCloser {
return &nopWriteCloser{w}
}
// NopFlusher represents a type which flush operation is nop.
type NopFlusher struct{}
// Flush is a nop operation.
func (f *NopFlusher) Flush() {}
type writeCloserWrapper struct {
io.Writer
closer func() error
}
func (r *writeCloserWrapper) Close() error {
return r.closer()
}
// NewWriteCloserWrapper returns a new io.WriteCloser.
func NewWriteCloserWrapper(w io.Writer, closer func() error) io.WriteCloser {
return &writeCloserWrapper{
Writer: w,
closer: closer,
}
}
// WriteCounter wraps a concrete io.Writer and hold a count of the number
// of bytes written to the writer during a "session".
// This can be convenient when write return is masked
// (e.g., json.Encoder.Encode())
type WriteCounter struct {
Count int64
Writer io.Writer
}
// NewWriteCounter returns a new WriteCounter.
func NewWriteCounter(w io.Writer) *WriteCounter {
return &WriteCounter{
Writer: w,
}
}
func (wc *WriteCounter) Write(p []byte) (int, error) {
count, err := wc.Writer.Write(p)
wc.Count += int64(count)
return count, err
}