bitstream

package module
v0.0.0-...-758b191 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2015 License: MIT Imports: 3 Imported by: 1

README

bitstream

A library for reading bits instead of bytes at a time

Please see godoc for documentation: http://godoc.org/github.com/aarondl/bitstream

Documentation

Overview

Package bitstream is used to read bits out of any given reader. It can operate in regular or "shift up" mode which determines how reads across byte-alignment construct values (with the current or the next byte able to become the most significant bits). It also has optimized fast-paths on byte alignments.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reader

type Reader struct {

	// Bits returns the next bits up to a max of 64.
	Bits func(nBits int) (val uint64, err error)
	// Bytes returns the number of requested bits inside a byte array.
	Bytes func(dst []byte, nBits int) (err error)
	// contains filtered or unexported fields
}

Reader reads many different types of values outside byte alignments.

func New

func New(reader io.Reader) *Reader

New constructs a reader that shifts the next byte up to become the most significant bits. Given data: 1010 0000 | 0000 0101, a read of Bits(16) will yield: 0000 0101 1010 0000

func NewShiftUp

func NewShiftUp(reader io.Reader) *Reader

NewShiftUp constructs a reader that shifts the current byte up to become the most significant bits. Given data: 1010 0000 | 0000 0101, a read of Bits(16) will yield: 1010 0000 0000 0101

func (*Reader) Align

func (r *Reader) Align()

Align discards the rest of the current byte's bits and byte-aligns the reader.

func (*Reader) Byte

func (r *Reader) Byte() (byte, error)

Byte from the reader.

func (*Reader) Read

func (r *Reader) Read(dst []byte) (int, error)

Read whole bytes from the reader.

Jump to

Keyboard shortcuts

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