endian

package module
v0.0.0-...-3b37b1e Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2023 License: BSD-2-Clause Imports: 4 Imported by: 1

README

Host byte order for GOPL coders


 var endian.HostOrder ByteOrder


  Implements host byte order determination as one of two
  principals: large or small.  N.B. Ancient alternatives
  from antiquity are ignored.


References

 [WIKI] https://en.wikipedia.org/wiki/Endianness
 [BINC] https://pkg.go.dev/encoding/binary
 [GOPL] https://go.dev/

Documentation

Overview

* Host byte order for GOPL coders * Copyright 2023 John Douglas Pritchard, Syntelos * * * Implements host byte order determination as one of two * principals: large or small. N.B. Ancient alternatives * from antiquity are ignored. * * * References * * https://en.wikipedia.org/wiki/Endianness * https://pkg.go.dev/encoding/binary

* RAND * Copyright 2023 John Douglas Pritchard, @syntelos

Index

Constants

View Source
const ByteOrderLargeName string = "big-endian"
View Source
const ByteOrderSmallName string = "little-endian"

Variables

This section is empty.

Functions

func Rand16

func Rand16() (v uint16, e error)

func Rand32

func Rand32() (v uint32, e error)

func Rand64

func Rand64() (v uint64, e error)

Types

type ByteOrder

type ByteOrder interface {
	/*
	 * Block
	 */
	EncodeUint16(uint16) []byte
	DecodeUint16([]byte) uint16

	EncodeUint32(uint32) []byte
	DecodeUint32([]byte) uint32

	EncodeUint64(uint64) []byte
	DecodeUint64([]byte) uint64
	/*
	 * Stream
	 */
	WriteUint16(io.Writer, uint16) (int, error)
	ReadUint16(io.ByteReader) (uint16, error)

	WriteUint32(io.Writer, uint32) (int, error)
	ReadUint32(io.ByteReader) (uint32, error)

	WriteUint64(io.Writer, uint64) (int, error)
	ReadUint64(io.ByteReader) (uint64, error)
	/*
	 * User
	 */
	String() string
}

* Byte order type abstraction to support host byte order. * N.B. Block operations do not check array object * boundaries.

var HostOrder ByteOrder = hostByteOrder()

type ByteOrderLarge

type ByteOrderLarge struct{}
var BigEndian ByteOrderLarge

func (ByteOrderLarge) DecodeUint16

func (ByteOrderLarge) DecodeUint16(r []byte) (v uint16)

func (ByteOrderLarge) DecodeUint32

func (ByteOrderLarge) DecodeUint32(r []byte) (v uint32)

func (ByteOrderLarge) DecodeUint64

func (ByteOrderLarge) DecodeUint64(r []byte) (v uint64)

func (ByteOrderLarge) EncodeUint16

func (ByteOrderLarge) EncodeUint16(v uint16) (w []byte)

func (ByteOrderLarge) EncodeUint32

func (ByteOrderLarge) EncodeUint32(v uint32) (w []byte)

func (ByteOrderLarge) EncodeUint64

func (ByteOrderLarge) EncodeUint64(v uint64) (w []byte)

func (ByteOrderLarge) ReadUint16

func (ByteOrderLarge) ReadUint16(r io.ByteReader) (v uint16, e error)

func (ByteOrderLarge) ReadUint32

func (ByteOrderLarge) ReadUint32(r io.ByteReader) (v uint32, e error)

func (ByteOrderLarge) ReadUint64

func (ByteOrderLarge) ReadUint64(r io.ByteReader) (v uint64, e error)

func (ByteOrderLarge) String

func (ByteOrderLarge) String() string

func (ByteOrderLarge) WriteUint16

func (ByteOrderLarge) WriteUint16(w io.Writer, v uint16) (c int, e error)

func (ByteOrderLarge) WriteUint32

func (ByteOrderLarge) WriteUint32(w io.Writer, v uint32) (c int, e error)

func (ByteOrderLarge) WriteUint64

func (ByteOrderLarge) WriteUint64(w io.Writer, v uint64) (c int, e error)

type ByteOrderSmall

type ByteOrderSmall struct{}

* Abstractions

var LilEndian ByteOrderSmall

* Practicals

func (ByteOrderSmall) DecodeUint16

func (ByteOrderSmall) DecodeUint16(r []byte) (v uint16)

func (ByteOrderSmall) DecodeUint32

func (ByteOrderSmall) DecodeUint32(r []byte) (v uint32)

func (ByteOrderSmall) DecodeUint64

func (ByteOrderSmall) DecodeUint64(r []byte) (v uint64)

func (ByteOrderSmall) EncodeUint16

func (ByteOrderSmall) EncodeUint16(v uint16) (w []byte)

func (ByteOrderSmall) EncodeUint32

func (ByteOrderSmall) EncodeUint32(v uint32) (w []byte)

func (ByteOrderSmall) EncodeUint64

func (ByteOrderSmall) EncodeUint64(v uint64) (w []byte)

func (ByteOrderSmall) ReadUint16

func (ByteOrderSmall) ReadUint16(r io.ByteReader) (v uint16, e error)

func (ByteOrderSmall) ReadUint32

func (ByteOrderSmall) ReadUint32(r io.ByteReader) (v uint32, e error)

func (ByteOrderSmall) ReadUint64

func (ByteOrderSmall) ReadUint64(r io.ByteReader) (v uint64, e error)

func (ByteOrderSmall) String

func (ByteOrderSmall) String() string

func (ByteOrderSmall) WriteUint16

func (ByteOrderSmall) WriteUint16(w io.Writer, v uint16) (c int, e error)

func (ByteOrderSmall) WriteUint32

func (ByteOrderSmall) WriteUint32(w io.Writer, v uint32) (c int, e error)

func (ByteOrderSmall) WriteUint64

func (ByteOrderSmall) WriteUint64(w io.Writer, v uint64) (c int, e error)

Jump to

Keyboard shortcuts

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