binio

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package binio provides high-performance functionality for binary IO.

The package is currently thread-unsafe, even when writing to different writers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBit

func GetBit(b []byte, n int) int

GetBit returns the value of the n'th bit in a byte slice.

func GetHalfByte

func GetHalfByte(b []byte, n int) byte

GetHalfByte returns the value of the n'th half byte (4 bits) in a byte slice.

func ReadByte

func ReadByte(r io.Reader) (byte, error)

ReadByte reads a byte from the given writer. Saves the need to create and keep a buffer for reading.

func ReadBytes

func ReadBytes(r io.Reader) ([]byte, error)

ReadBytes reads a slice of bytes from the given writer.

func ReadString

func ReadString(r io.Reader) (string, error)

ReadString reads a string from the given writer.

func ReadUint64

func ReadUint64(r io.Reader) (uint64, error)

ReadUint64 reads a uint64 from the given reader.

func ReadUvarint

func ReadUvarint(r io.Reader) (uint64, error)

ReadUvarint reads a varint-encoded uint64 from the given reader.

func SetBit

func SetBit(b []byte, n, v int)

SetBit sets the value of the n'th bit in a byte slice.

func SetHalfByte

func SetHalfByte(b []byte, n int, v byte)

SetHalfByte sets the value of the n'th half byte (4 bits) in a byte slice.

func Uint64FromBytes

func Uint64FromBytes(b []byte) uint64

Uint64FromBytes returns the number represented by the given slice.

func Uint64ToBytes

func Uint64ToBytes(x uint64, b []byte)

Uint64ToBytes populates the first 8 bytes in the given slice with the given number.

func WriteByte

func WriteByte(w io.Writer, b byte) error

WriteByte writes a byte to the given writer. Saves the need to create and keep a buffer for writing.

func WriteBytes

func WriteBytes(w io.Writer, b []byte) error

WriteBytes writes a slice of bytes to the given writer.

func WriteString

func WriteString(w io.Writer, s string) error

WriteString writes a string to the given writer.

func WriteUint64

func WriteUint64(w io.Writer, x uint64) error

WriteUint64 writes a uint64 to the given writer.

func WriteUvarint

func WriteUvarint(w io.Writer, x uint64) error

WriteUvarint writes a varint-encoded uint64 to the given writer.

Types

This section is empty.

Jump to

Keyboard shortcuts

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