-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplz4_reader.go
33 lines (27 loc) · 947 Bytes
/
plz4_reader.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package plz4
import (
"io"
"github.com/prequel-dev/plz4/internal/pkg/rdr"
)
// Reader is an interface for reading LZ4 compressed data.
//
// It implements the io.ReadCloser and the io.WriterTo interfaces.
type Reader interface {
// Read decompressed data into 'dst'. Return number bytes read.
Read(dst []byte) (n int, err error)
// Decompress to 'wr'. Return number bytes written.
WriteTo(wr io.Writer) (int64, error)
// Close the Reader to release underlying resources.
// Close() *MUST* be called on completion whether or not
// the Reader is in an error state.
Close() error
}
// Construct a Reader to decompress the LZ4 frame from 'rd'.
//
// Specify optional parameters in 'opts'.
func NewReader(rd io.Reader, opts ...OptT) Reader {
// 'o' will escape as we are taking a ptr in Reader.
// We do this to save space since also passing to underlying implementation.
o := parseOpts(opts...)
return rdr.NewReader(rd, &o)
}