about summary refs log tree commit diff
path: root/tvix/nar-bridge/pkg/importer/counting_writer.go
blob: d003a4b11bfdf0fff4861efb9ec527ef882224a6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package importer

import (
	"io"
)

// CountingWriter implements io.Writer.
var _ io.Writer = &CountingWriter{}

type CountingWriter struct {
	bytesWritten uint64
}

func (cw *CountingWriter) Write(p []byte) (n int, err error) {
	cw.bytesWritten += uint64(len(p))
	return len(p), nil
}

func (cw *CountingWriter) BytesWritten() uint64 {
	return cw.bytesWritten
}