edge/pkg/bundle/oldzim/zstd_reader.go

27 lines
389 B
Go
Raw Normal View History

2023-07-11 02:42:05 +02:00
package zim
import (
"fmt"
"io"
"github.com/klauspost/compress/zstd"
)
type ZstdReader struct {
*zstd.Decoder
}
func NewZstdReader(r io.Reader) (*ZstdReader, error) {
dec, err := zstd.NewReader(r)
if err != nil {
return nil, fmt.Errorf("can't read from zstd %w", err)
}
return &ZstdReader{dec}, nil
}
func (zr *ZstdReader) Close() error {
zr.Decoder.Close()
return nil
}