bitter

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

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

Go to latest
Published: Aug 1, 2021 License: MIT Imports: 1 Imported by: 0

README

bitter

small helper library for helping build custom protocols

Documentation

Index

Constants

View Source
const (
	Lo    QuartetPosition = 0
	Hi    QuartetPosition = 1
	QBit0 QuartetIndex    = 0
	QBit1 QuartetIndex    = 1
	QBit2 QuartetIndex    = 2
	QBit3 QuartetIndex    = 3
	Bit0  OctetIndex      = 0
	Bit1  OctetIndex      = 1
	Bit2  OctetIndex      = 2
	Bit3  OctetIndex      = 3
	Bit4  OctetIndex      = 4
	Bit5  OctetIndex      = 5
	Bit6  OctetIndex      = 6
	Bit7  OctetIndex      = 7
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Octet

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

func OctetFromByte

func OctetFromByte(b byte) *Octet

func OctetFromQuartets

func OctetFromQuartets(hi, lo *Quartet) *Octet

func (*Octet) BinaryString

func (o *Octet) BinaryString() string

BinaryString returns the binary representation of the octet

func (*Octet) Byte

func (o *Octet) Byte() byte

Byte returns the protected byte that holds the Octet bit values

func (*Octet) HexString

func (o *Octet) HexString() string

func (*Octet) IsSet

func (o *Octet) IsSet(index OctetIndex) bool

IsSet checks if the bit at a given position is set

func (*Octet) Nullify

func (o *Octet) Nullify() *Octet

Nullify zeroes out (ie Unset) all the bits in the Octet

func (*Octet) OctetMap

func (o *Octet) OctetMap() OctetMap

OctetMap

func (*Octet) Overwrite

func (o *Octet) Overwrite(val byte) *Octet

Overwrite all bits in the octet with the values from a byte

func (*Octet) OverwriteQuartet

func (o *Octet) OverwriteQuartet(val *Quartet, pos QuartetPosition) *Octet

OverwriteQuartet all bits in the octet with the values from a byte

func (*Octet) QuartetMaps

func (o *Octet) QuartetMaps() (hi, lo QuartetMap)

QuartetMaps gets the hi and lo nibbles in an Octet as boolean maps

func (*Octet) Quartets

func (o *Octet) Quartets() (hi, lo *Quartet)

func (*Octet) Set

func (o *Octet) Set(index OctetIndex) *Octet

Set the bit to 1 at a given position in the byte

func (*Octet) Toggle

func (o *Octet) Toggle(index OctetIndex) *Octet

Toggle the value of the bit at the given position in the byte

func (*Octet) Unset

func (o *Octet) Unset(index OctetIndex) *Octet

Unset the bit at a given position in the byte

type OctetIndex

type OctetIndex int

type OctetMap

type OctetMap struct {
	B0 bool
	B1 bool
	B2 bool
	B3 bool
	B4 bool
	B5 bool
	B6 bool
	B7 bool
}

type Quartet

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

func QuartetsFromByte

func QuartetsFromByte(b byte) (hi, lo *Quartet)

func (*Quartet) IsSet

func (q *Quartet) IsSet(index QuartetIndex) bool

IsSet checks if the bit at a given position is set

func (*Quartet) Set

func (q *Quartet) Set(index QuartetIndex) *Quartet

Set the bit to 1 at a given position in the byte

func (*Quartet) Toggle

func (q *Quartet) Toggle(index QuartetIndex) *Quartet

Toggle the value of the bit at the given position in the byte

func (*Quartet) Unset

func (q *Quartet) Unset(index QuartetIndex) *Quartet

Unset the bit at a given position in the byte

type QuartetIndex

type QuartetIndex int

type QuartetMap

type QuartetMap struct {
	B0 bool
	B1 bool
	B2 bool
	B3 bool
}

type QuartetPosition

type QuartetPosition int

Jump to

Keyboard shortcuts

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