1
1
mirror of https://github.com/wader/fq.git synced 2024-09-20 08:18:51 +03:00
fq/pkg/bitio/README.md
Mattias Wadman 7c5215347d bitio,decode: Refactor bitio usage and make buffer slicing more correct
Remove bitio.Buffer layer. bitio.Buffer was a kitchen sink layer with helpers
now it's just a buffer and most functions have been moved to decode instead.

bitio package now only have primitive types and functions simialar to standard
library io and bytes packages.

Make nearly eveything internally use bitio.Bit* interfaces so that slicing work
correctly this will also make it possible to start experimenting with more
complicated silcing helpers, ex things like:
breplace(.header.bitrate; 123) to get a new buffer with bitrate changed.
2022-02-04 21:41:53 +01:00

1009 B

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?)