1
1
mirror of https://github.com/wader/fq.git synced 2024-11-25 14:12:13 +03:00

bitio: More doc cleanup

This commit is contained in:
Mattias Wadman 2022-02-09 01:02:48 +01:00
parent d1c75543ed
commit 82aeb35591
6 changed files with 39 additions and 21 deletions

View File

@ -1,18 +0,0 @@
The bitio package tries to mimic the standard library packages io and bytes as much as possible.
- bitio.Buffer same as bytes.Buffer
- bitio.IOBitReadSeeker is a bitio.ReaderAtSeeker that from a io.ReadSeeker
- bitio.IOBitWriter a bitio.BitWriter that write bytes to a io.Writer, use Flush() to write possible unaligned byte
- bitio.IOReader is a io.Reader that reads bytes from a bit reader, will zero pad on unaligned byte eof
- bitio.IOReadSeeker is a io.ReadSeeker that read/seek bytes in a bit stream, will zero pad on unaligned - bitio.NewBitReader same as bytes.NewReader
- bitio.LimitReader same as io.LimitReader
- bitio.MultiReader same as io.MultiReader
- bitio.SectionReader same as io.SectionReader
- bitio.Copy* same as io.Copy*
- bitio.ReadFull same as io.ReadFull
TODO:
- bitio.IOBitReader bitio.Reader that reads from a io.Reader
- bitio.IOBitWriteSeeker bitio.BitWriteSeeker that writes to a io.WriteSeeker
- bitio.CopyN
- speed up read by using a cache somehow ([]byte or just a uint64?)

34
pkg/bitio/doc.go Normal file
View File

@ -0,0 +1,34 @@
// Package bitio tries to mimic the standard library packages io and bytes but for bits.
//
// - bitio.Buffer same as bytes.Buffer
//
// - bitio.IOBitReadSeeker is a bitio.ReaderAtSeeker that reads from a io.ReadSeeker
//
// - bitio.IOBitWriter a bitio.BitWriter that writes to a io.Writer, use Flush() to write possible zero padded unaligned byte
//
// - bitio.IOReader is a io.Reader that reads bytes from a bitio.Reader, will zero pad unaligned byte at EOF
//
// - bitio.IOReadSeeker is a io.ReadSeeker that reads from a bitio.ReadSeeker, will zero pad unaligned byte at EOF
//
// - bitio.NewBitReader same as bytes.NewReader
//
// - bitio.LimitReader same as io.LimitReader
//
// - bitio.MultiReader same as io.MultiReader
//
// - bitio.SectionReader same as io.SectionReader
//
// - bitio.Copy* same as io.Copy*
//
// - bitio.ReadFull same as io.ReadFull
//
// TODO:
//
// - bitio.IOBitReader bitio.Reader that reads from a io.Reader
//
// - bitio.IOBitWriteSeeker bitio.BitWriteSeeker that writes to a io.WriteSeeker
//
// - bitio.CopyN
//
// - Speed up read by using a cache somehow ([]byte or just a uint64?)
package bitio

View File

@ -5,7 +5,7 @@ import (
"io" "io"
) )
// IOBitReadSeeker is a bitio.BitReadAtSeeker reading from a io.ReadSeeker // IOBitReadSeeker is a bitio.ReadAtSeeker reading from a io.ReadSeeker
type IOBitReadSeeker struct { type IOBitReadSeeker struct {
bitPos int64 bitPos int64
rs io.ReadSeeker rs io.ReadSeeker

View File

@ -4,7 +4,7 @@ import (
"io" "io"
) )
// IOBitWriter is a bitio.BitWriter that writes to a io.Writer // IOBitWriter is a bitio.Writer that writes to a io.Writer
// Use Flush to write possible unaligned byte zero bit padded. // Use Flush to write possible unaligned byte zero bit padded.
type IOBitWriter struct { type IOBitWriter struct {
w io.Writer w io.Writer

View File

@ -1,6 +1,6 @@
package bitio package bitio
// IOReadSeeker is a io.ReadSeeker that reads and seeks from a bitio.BitReadSeeker // IOReadSeeker is a io.ReadSeeker that reads from a bitio.ReadSeeker
// Unaligned byte at EOF will be zero bit padded // Unaligned byte at EOF will be zero bit padded
type IOReadSeeker struct { type IOReadSeeker struct {
IOReader IOReader

View File

@ -90,6 +90,8 @@ func Read64(buf []byte, firstBit int64, nBits int64) uint64 {
return n return n
} }
// Write64 writes nBits bits large unsigned integer to buf starting from firstBit.
// Integer is written most significant bit first.
func Write64(v uint64, nBits int64, buf []byte, firstBit int64) { func Write64(v uint64, nBits int64, buf []byte, firstBit int64) {
if nBits < 0 || nBits > 64 { if nBits < 0 || nBits > 64 {
panic(fmt.Sprintf("nBits must be 0-64 (%d)", nBits)) panic(fmt.Sprintf("nBits must be 0-64 (%d)", nBits))