Skip to content

Commit

Permalink
docs: improve interface documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
SaveTheRbtz committed Apr 16, 2022
1 parent a5dd590 commit aa47a19
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
5 changes: 2 additions & 3 deletions decoder.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package seekable

import (
"io"

"github.com/google/btree"

"github.com/SaveTheRbtz/zstd-seekable-format-go/env"
Expand All @@ -25,7 +23,8 @@ type Decoder interface {
// NumFrames returns number of frames in the compressed stream.
NumFrames() int64

io.Closer
// Close closes the decoder feeing up any resources.
Close() error
}

// NewDecoder creates a byte-oriented Decode interface from a given seektable index.
Expand Down
1 change: 1 addition & 0 deletions encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
type Encoder interface {
// Encode returns compressed data and appends a frame to in-memory seek table.
Encode(src []byte) ([]byte, error)

// EndStream returns in-memory seek table as a ZSTD's skippable frame.
EndStream() ([]byte, error)
}
Expand Down
8 changes: 4 additions & 4 deletions reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,20 @@ type Reader interface {
// Seek implements io.Seeker interface to randomly access data.
// This method is NOT goroutine-safe and CAN NOT be called
// concurrently since it modifies the underlying offset.
io.Seeker
Seek(offset int64, whence int) (int64, error)

// Read implements io.Reader interface to sequentially access data.
// This method is NOT goroutine-safe and CAN NOT be called
// concurrently since it modifies the underlying offset.
io.Reader
Read(p []byte) (n int, err error)

// ReadAt implements io.ReaderAt interface to randomly access data.
// This method is goroutine-safe and can be called concurrently ONLY if
// the underlying reader supports io.ReaderAt interface.
io.ReaderAt
ReadAt(p []byte, off int64) (n int, err error)

// Close implements io.Closer interface free up any resources.
io.Closer
Close() error
}

// ZSTDDecoder is the decompressor. Tested with github.com/klauspost/compress/zstd.
Expand Down
5 changes: 3 additions & 2 deletions writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ type Writer interface {
//
// Note that Write does not do any coalescing nor splitting of data,
// so each write will map to a separate ZSTD Frame.
io.Writer
Write(src []byte) (int, error)

// Close implement io.Closer interface. It writes the seek table footer
// and releases occupied memory.
//
// Caller is still responsible to Close the underlying writer.
io.Closer
Close() (err error)
}

// ZSTDEncoder is the compressor. Tested with github.com/klauspost/compress/zstd.
Expand Down

0 comments on commit aa47a19

Please sign in to comment.