binio

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBit

func GetBit(p uint64, i int) bool

GetBit gets bit i within p.

func GetBits

func GetBits(p uint64, i, j int) int

GetBits gets bits i through j within p.

func SetBit

func SetBit(p uint64, i int, v bool) uint64

SetBit sets bit i within p to v, returning the new value of p.

func SetBits

func SetBits(p uint64, i, j, v int) uint64

SetBits sets bits i through j within p to v, returning the new value of p.

Types

type Reader

type Reader struct {
	Err error
	// contains filtered or unexported fields
}

Reader is a wrapper that keeps track of the number of bytes written.

func NewReader

func NewReader(r io.Reader) *Reader

func (*Reader) Bytes

func (r *Reader) Bytes(p []byte) (ok bool)

Bytes reads len(p) bytes into p.

func (*Reader) BytesRead

func (r *Reader) BytesRead() int64

BytesRead returns the number of bytes read.

func (*Reader) End

func (r *Reader) End() (n int64, err error)

End returns the number of read bytes and any error that occurred.

func (*Reader) Number

func (r *Reader) Number(data interface{}) (ok bool)

Number reads a binary integer. data must be a pointer to a number type.

func (*Reader) Read

func (r *Reader) Read(p []byte) (n int, err error)

Read implements the io.Reader interface.

func (*Reader) String

func (r *Reader) String(data *string) (ok bool)

String reads a short string into data. The first byte is read, indicating the length of the string, and then a number of bytes is read equal to the length.

type Writer

type Writer struct {
	Err error
	// contains filtered or unexported fields
}

Writer is a wrapper that keeps track of the number of bytes written.

func NewWriter

func NewWriter(w io.Writer) *Writer

func (*Writer) Bytes

func (w *Writer) Bytes(p []byte) (ok bool)

Bytes writes p as bytes.

func (*Writer) BytesWritten

func (w *Writer) BytesWritten() int64

BytesWritten returns the number of bytes written.

func (*Writer) End

func (w *Writer) End() (n int64, err error)

End returns the number of written bytes and any error that occurred.

func (*Writer) Number

func (w *Writer) Number(data interface{}) (ok bool)

Number writes data as a binary integer.

func (*Writer) String

func (w *Writer) String(data string) (ok bool)

String writes data as a short string. The first written byte is the length, followed by the byte content of the string.

func (*Writer) Write

func (w *Writer) Write(p []byte) (n int, err error)

Write implements the io.Writer interface.

Jump to

Keyboard shortcuts

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