bitstream

package module
v0.0.0-...-e6da236 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2019 License: MIT Imports: 3 Imported by: 0

README

bitstream: read and write bits from io.Reader and io.Writer streams

Full package documentation available at: http://godoc.org/github.com/dgryski/go-bitstream

Documentation

Overview

Package bitstream is a simple wrapper around a io.Reader and io.Writer to provide bit-level access to the stream.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bit

type Bit bool

A Bit is a zero or a one

const (
	// Zero is our exported type for '0' bits
	Zero Bit = false
	// One is our exported type for '1' bits
	One = true
)

type BitReader

type BitReader struct {
	// contains filtered or unexported fields
}

A BitReader reads bits from an io.Reader

func NewReader

func NewReader(r io.Reader) *BitReader

NewReader returns a BitReader that returns a single bit at a time from 'r'

func (*BitReader) Align

func (b *BitReader) Align()

func (*BitReader) DumpAll

func (b *BitReader) DumpAll() ([]byte, error)

func (*BitReader) GetReader

func (b *BitReader) GetReader() io.Reader

func (*BitReader) Read

func (b *BitReader) Read(dest []byte) error

Implements io.Reader Optimized for aligned reads

func (*BitReader) ReadBit

func (b *BitReader) ReadBit() (Bit, error)

ReadBit returns the next bit from the stream, reading a new byte from the underlying reader if required.

func (*BitReader) ReadBits

func (b *BitReader) ReadBits(nbits int) (uint64, error)

ReadBits reads nbits from the stream

func (*BitReader) ReadByte

func (b *BitReader) ReadByte() (byte, error)

ReadByte reads a single byte from the stream, regardless of alignment

type BitWriter

type BitWriter struct {
	// contains filtered or unexported fields
}

A BitWriter writes bits to an io.Writer

func NewWriter

func NewWriter(w io.Writer) *BitWriter

NewWriter returns a BitWriter that buffers bits and write the resulting bytes to 'w'

func (*BitWriter) Align

func (b *BitWriter) Align() error

func (*BitWriter) Flush

func (b *BitWriter) Flush(bit Bit) error

Flush empties the currently in-process byte by filling it with 'bit'.

func (*BitWriter) Pending

func (b *BitWriter) Pending() (byt byte, vals uint8)

func (*BitWriter) Resume

func (b *BitWriter) Resume(data byte, count uint8)

func (*BitWriter) Write

func (b *BitWriter) Write(data []byte) (int, error)

func (*BitWriter) WriteBit

func (b *BitWriter) WriteBit(bit Bit) error

WriteBit writes a single bit to the stream, writing a new byte to 'w' if required.

func (*BitWriter) WriteBits

func (b *BitWriter) WriteBits(u uint64, nbits int) error

WriteBits writes the nbits least significant bits of u, most-significant-bit first.

func (*BitWriter) WriteByte

func (b *BitWriter) WriteByte(byt byte) error

WriteByte writes a single byte to the stream, regardless of alignment

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL