Add a rac.CodecReader abstraction

This commit is contained in:
Nigel Tao committed 2019-08-08 12:09:25 +10:00
1 parent 635c3c8fe9
commit cdf49196b1
4 files changed
+71 -128

No files matched your search

+6 -3
View File
@@ -20,12 +20,14 @@ import (
"io"
"log"
"github.com/google/wuffs/lib/rac"
"github.com/google/wuffs/lib/raczlib"
)
// Example_roundTrip demonstrates compressing (using a raczlib.Writer) and
// decompressing (using a raczlib.Reader). This includes decompressing an
// excerpt of the original data, exercising the "random access" part of RAC.
// decompressing (using a rac.Reader configured with a raczlib.CodecReader).
// This includes decompressing an excerpt of the original data, exercising the
// "random access" part of RAC.
func Example_roundTrip() {
// Create some test data.
oBuf := &bytes.Buffer{}
@@ -67,9 +69,10 @@ func Example_roundTrip() {
}
// Prepare to decompress.
r := &raczlib.Reader{
r := &rac.Reader{
ReadSeeker: bytes.NewReader(compressed),
CompressedSize: int64(len(compressed)),
CodecReaders: []rac.CodecReader{&raczlib.CodecReader{}},
}
// Read the whole file.