27 lines
389 B
Go
27 lines
389 B
Go
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
|
|
}
|