Documentation
¶
Index ¶
- Variables
- func BitStringFromBytes(buf []byte, nBits int) string
- func BitsByteCount(nBits int64) int64
- func BytesFromBitString(s string) ([]byte, int)
- func Copy(dst BitWriter, src BitReader) (n int64, err error)
- func CopyBuffer(dst BitWriter, src BitReader, buf []byte) (n int64, err error)
- func EndPos(rs BitSeeker) (int64, error)
- func Read64(buf []byte, firstBit int, nBits int) uint64
- func ReadAtFull(r BitReaderAt, p []byte, nBits int, bitOff int64) (int, error)
- func ReadFull(r BitReader, p []byte, nBits int) (int, error)
- func ReverseBytes(bs []byte) []byte
- func Uint64ReverseBytes(nBits int, n uint64) uint64
- func Write64(v uint64, nBits int, buf []byte, firstBit int)
- type BitReadAtSeeker
- type BitReadSeeker
- type BitReader
- type BitReaderAt
- type BitSeeker
- type BitWriter
- type Buffer
- func (b *Buffer) AlignBits(nBits int) (int, error)
- func (b *Buffer) BitBufLen(nBits int64) (*Buffer, error)
- func (b *Buffer) BitBufRange(firstBitOffset int64, nBits int64) (*Buffer, error)
- func (b *Buffer) BitString() (string, error)
- func (b *Buffer) BitsLeft() (int64, error)
- func (b *Buffer) ByteAlignBits() (int, error)
- func (b *Buffer) BytePos() (int64, error)
- func (b *Buffer) Bytes() ([]byte, error)
- func (b *Buffer) BytesLen(nBytes int) ([]byte, error)
- func (b *Buffer) BytesRange(bitOffset int64, nBytes int) ([]byte, error)
- func (b *Buffer) Clone() *Buffer
- func (b *Buffer) End() (bool, error)
- func (b *Buffer) Len() int64
- func (b *Buffer) PeekBytes(nBytes int) ([]byte, error)
- func (b *Buffer) Pos() (int64, error)
- func (b *Buffer) ReadByte() (byte, error)
- func (b *Buffer) SeekAbs(pos int64) (int64, error)
- func (b *Buffer) SeekRel(delta int64) (int64, error)
- func (b *Buffer) String() string
- type MultiBitReader
- func (m *MultiBitReader) Read(p []byte) (n int, err error)
- func (m *MultiBitReader) ReadBits(p []byte, nBits int) (n int, err error)
- func (m *MultiBitReader) ReadBitsAt(p []byte, nBits int, bitOff int64) (n int, err error)
- func (m *MultiBitReader) Seek(offset int64, whence int) (int64, error)
- func (m *MultiBitReader) SeekBits(bitOff int64, whence int) (int64, error)
- type Reader
- func (r *Reader) Read(p []byte) (n int, err error)
- func (r *Reader) ReadBits(p []byte, nBits int) (n int, err error)
- func (r *Reader) ReadBitsAt(p []byte, nBits int, bitOffset int64) (int, error)
- func (r *Reader) Seek(offset int64, whence int) (int64, error)
- func (r *Reader) SeekBits(bitOff int64, whence int) (int64, error)
- type SectionBitReader
- func (r *SectionBitReader) Read(p []byte) (n int, err error)
- func (r *SectionBitReader) ReadBits(p []byte, nBits int) (n int, err error)
- func (r *SectionBitReader) ReadBitsAt(p []byte, nBits int, bitOff int64) (int, error)
- func (r *SectionBitReader) Seek(offset int64, whence int) (int64, error)
- func (r *SectionBitReader) SeekBits(bitOff int64, whence int) (int64, error)
Constants ¶
This section is empty.
Variables ¶
var ErrNegativeNBits = errors.New("negative number of bits")
var ErrOffset = errors.New("invalid seek offset")
Functions ¶
func BitStringFromBytes ¶
BitStringFromBytes string from []byte], ex: ([]byte{0x50}, 4) -> "0101"
func BitsByteCount ¶
BitsByteCount returns smallest amount of bytes to fit nBits bits
func BytesFromBitString ¶
BytesFromBitString []byte from bit string, ex: "0101" -> ([]byte{0x50}, 4)
func Read64 ¶
Read64 read nBits bits large unsigned integer from buf starting from firstBit. Integer is read most significant bit first.
func ReadAtFull ¶
func ReverseBytes ¶
func Uint64ReverseBytes ¶
Types ¶
type BitReadAtSeeker ¶
type BitReadAtSeeker interface {
BitReaderAt
BitSeeker
}
type BitReadSeeker ¶
type BitReaderAt ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer is a bit buffer
func NewBufferFromBitString ¶
NewBufferFromBitString new Buffer from bit string, ex: "0101"
func NewBufferFromBytes ¶
NewBufferFromBytes new Buffer from bytes if nBits is < 0 nBits is all bits in buf
func NewBufferFromReadSeeker ¶
func NewBufferFromReadSeeker(rs io.ReadSeeker) (*Buffer, error)
NewBufferFromReadSeeker new Buffer from io.ReadSeeker, start at firstBit with bit length lenBits buf is not copied.
func (*Buffer) BitBufRange ¶
BitBufRange reads nBits bits starting from start Does not update current position. if nBits is < 0 nBits is all bits after firstBitOffset
func (*Buffer) ByteAlignBits ¶
ByteAlignBits number of bits to next byte align
func (*Buffer) BytesRange ¶
BytesRange reads nBytes bytes starting bit position start Does not update current position. TODO: swap args TODO: nBytes -1?
type MultiBitReader ¶
type MultiBitReader struct {
// contains filtered or unexported fields
}
TODO: smart, track index?
func NewMultiBitReader ¶
func NewMultiBitReader(rs []BitReadAtSeeker) (*MultiBitReader, error)
func (*MultiBitReader) ReadBits ¶
func (m *MultiBitReader) ReadBits(p []byte, nBits int) (n int, err error)
func (*MultiBitReader) ReadBitsAt ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader is a BitReadSeeker and BitReaderAt reading from a io.ReadSeeker
func NewReaderFromReadSeeker ¶
func NewReaderFromReadSeeker(rs io.ReadSeeker) *Reader
func (*Reader) ReadBitsAt ¶
type SectionBitReader ¶
type SectionBitReader struct {
// contains filtered or unexported fields
}
SectionBitReader is a BitReadSeeker reading from a BitReaderAt modelled after io.SectionReader
func NewSectionBitReader ¶
func NewSectionBitReader(r BitReaderAt, bitOff int64, nBits int64) *SectionBitReader
func (*SectionBitReader) ReadBits ¶
func (r *SectionBitReader) ReadBits(p []byte, nBits int) (n int, err error)