binaryutil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2019 License: CC0-1.0 Imports: 2 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadByte

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

ReadByte reads a byte from the io.Reader r using the slice p for temporary storage. The slice p must be of length at least 1, otherwise an io.ErrShortBuffer error will be returned. Note that this will NOT check to see if r satisfies the io.ByteReader interface.

func ReadInt16

func ReadInt16(r io.Reader, e binary.ByteOrder, p []byte) (int16, error)

ReadInt16 reads an int16 from the io.Reader r with byte order e, using the slice p for temporary storage. The slice p must be of length at least 2, otherwise an io.ErrShortBuffer error will be returned.

func ReadInt32

func ReadInt32(r io.Reader, e binary.ByteOrder, p []byte) (int32, error)

ReadInt32 reads an int32 from the io.Reader r with byte order e, using the slice p for temporary storage. The slice p must be of length at least 4, otherwise an io.ErrShortBuffer error will be returned.

func ReadInt64

func ReadInt64(r io.Reader, e binary.ByteOrder, p []byte) (int64, error)

ReadInt64 reads an int64 from the io.Reader r with byte order e, using the slice p for temporary storage. The slice p must be of length at least 8, otherwise an io.ErrShortBuffer error will be returned.

func ReadInt8

func ReadInt8(r io.Reader, p []byte) (int8, error)

ReadInt8 reads an int8 from the io.Reader r using the slice p for temporary storage. The slice p must be of length at least 1, otherwise an io.ErrShortBuffer error will be returned.

func ReadUint16

func ReadUint16(r io.Reader, e binary.ByteOrder, p []byte) (uint16, error)

ReadUint16 reads a uint16 from the io.Reader r with byte order e, using the slice p for temporary storage. The slice p must be of length at least 2, otherwise an io.ErrShortBuffer error will be returned.

func ReadUint32

func ReadUint32(r io.Reader, e binary.ByteOrder, p []byte) (uint32, error)

ReadUint32 reads a uint32 from the io.Reader r with byte order e, using the slice p for temporary storage. The slice p must be of length at least 4, otherwise an io.ErrShortBuffer error will be returned.

func ReadUint64

func ReadUint64(r io.Reader, e binary.ByteOrder, p []byte) (uint64, error)

ReadUint64 reads a uint64 from the io.Reader r with byte order e, using the slice p for temporary storage. The slice p must be of length at least 8, otherwise an io.ErrShortBuffer error will be returned.

func ReadUint8

func ReadUint8(r io.Reader, p []byte) (uint8, error)

ReadUint8 reads a uint8 from the io.Reader r using the slice p for temporary storage. The slice p must be of length at least 1, otherwise an io.ErrShortBuffer error will be returned.

func WriteByte

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

WriteByte write the byte b to the io.Writer w using the slice p for temporary storage. The slice p must be of length at least 1, otherwise an io.ErrShortBuffer error will be returned. Note that this will NOT check to see if w satisfies the io.ByteWriter interface.

func WriteInt16

func WriteInt16(w io.Writer, e binary.ByteOrder, m int16, p []byte) error

WriteInt16 writes the int16 m to the io.Writer w using the byte order e and the slice p for temporary storage. The slice p must be of length at least 2, otherwise an io.ErrShortBuffer error will be returned.

func WriteInt32

func WriteInt32(w io.Writer, e binary.ByteOrder, m int32, p []byte) error

WriteInt32 writes the int32 m to the io.Writer w using the byte order e and the slice p for temporary storage. The slice p must be of length at least 4, otherwise an io.ErrShortBuffer error will be returned.

func WriteInt64

func WriteInt64(w io.Writer, e binary.ByteOrder, m int64, p []byte) error

WriteInt64 writes the int64 m to the io.Writer w using the byte order e and the slice p for temporary storage. The slice p must be of length at least 8, otherwise an io.ErrShortBuffer error will be returned.

func WriteInt8

func WriteInt8(w io.Writer, m int8, p []byte) error

WriteInt8 writes the int8 m to the io.Writer w using the slice p for temporary storage. The slice p must be of length at least 1, otherwise an io.ErrShortBuffer error will be returned.

func WriteUint16

func WriteUint16(w io.Writer, e binary.ByteOrder, m uint16, p []byte) error

WriteUint16 writes the uint16 m to the io.Writer w using the byte order e and the slice p for temporary storage. The slice p must be of length at least 2, otherwise an io.ErrShortBuffer error will be returned.

func WriteUint32

func WriteUint32(w io.Writer, e binary.ByteOrder, m uint32, p []byte) error

WriteUint32 writes the uint32 m to the io.Writer w using the byte order e and the slice p for temporary storage. The slice p must be of length at least 4, otherwise an io.ErrShortBuffer error will be returned.

func WriteUint64

func WriteUint64(w io.Writer, e binary.ByteOrder, m uint64, p []byte) error

WriteUint64 writes the uint64 m to the io.Writer w using the byte order e and the slice p for temporary storage. The slice p must be of length at least 8, otherwise an io.ErrShortBuffer error will be returned.

func WriteUint8

func WriteUint8(w io.Writer, m uint8, p []byte) error

WriteUint8 writes the uint8 m to the io.Writer w using the slice p for temporary storage. The slice p must be of length at least 1, otherwise an io.ErrShortBuffer error will be returned.

Types

type BasicReader

type BasicReader interface {
	io.ByteReader
	ReadUint8() (uint8, error)   // ReadUint8 reads a uint8.
	ReadInt8() (int8, error)     // ReadInt8 reads an int8.
	ReadUint16() (uint16, error) // ReadUint16 reads a uint16.
	ReadInt16() (int16, error)   // ReadInt16 reads an int16.
	ReadUint32() (uint32, error) // ReadUint32 reads a uint32.
	ReadInt32() (int32, error)   // ReadInt32 reads an int32.
	ReadUint64() (uint64, error) // ReadUint64 reads a uint64.
	ReadInt64() (int64, error)   // ReadInt64 reads an int64.
}

BasicReader describes the interface for the basic methods to read binary data.

type BasicWriter

type BasicWriter interface {
	io.ByteWriter
	WriteUint8(m uint8) error   // WriteUint8 writes a uint8.
	WriteInt8(m int8) error     // WriteInt8 writes an int8.
	WriteUint16(m uint16) error // WriteUint16 writes a uint16.
	WriteInt16(m int16) error   // WriteInt16 writes an int16.
	WriteUint32(m uint32) error // WriteUint32 writes a uint32.
	WriteInt32(m int32) error   // WriteInt32 writes an int32.
	WriteUint64(m uint64) error // WriteUint64 writes a uint64.
	WriteInt64(m int64) error   // WriteInt64 writes an int64.
}

BasicWriter describes the interface for the basic methods to write binary data.

type BinaryReadWriter

type BinaryReadWriter interface {
	io.ReadWriter
	ByteOrderer
	BasicReader
	BasicWriter
}

BinaryReadWriter describes the interface for methods to read and write binary data.

type BinaryReader

type BinaryReader interface {
	io.Reader
	ByteOrderer
	BasicReader
}

BinaryReader describes the interface for methods to read binary data.

type BinaryWriter

type BinaryWriter interface {
	io.Writer
	ByteOrderer
	BasicWriter
}

BinaryWriter describes the interface for methods to write binary data.

type ByteOrderer

type ByteOrderer interface {
	ByteOrder() binary.ByteOrder // ByteOrder returns the byte order used.
}

ByteOrderer is the interface satisfied by the ByteOrder method.

type ReadCloser

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

ReadCloser wraps an io.ReadCloser and implements BinaryReader.

func NewReadCloser

func NewReadCloser(r io.ReadCloser, e binary.ByteOrder) *ReadCloser

NewReadCloser wraps the given io.ReadCloser as a BinaryReader using the given byte order.

func (*ReadCloser) ByteOrder

func (r *ReadCloser) ByteOrder() binary.ByteOrder

ByteOrder returns the byte order used.

func (*ReadCloser) Close

func (r *ReadCloser) Close() error

Close closes the underlying reader.

func (ReadCloser) Read

func (r ReadCloser) Read(b []byte) (int, error)

Read reads data from r.

func (ReadCloser) ReadByte

func (r ReadCloser) ReadByte() (byte, error)

ReadByte reads a byte from r.

func (ReadCloser) ReadInt16

func (r ReadCloser) ReadInt16() (int16, error)

ReadInt16 reads an int16 from r.

func (ReadCloser) ReadInt32

func (r ReadCloser) ReadInt32() (int32, error)

ReadInt32 reads an int32 from r.

func (ReadCloser) ReadInt64

func (r ReadCloser) ReadInt64() (int64, error)

ReadInt64 reads an int64 from r.

func (ReadCloser) ReadInt8

func (r ReadCloser) ReadInt8() (int8, error)

ReadInt8 reads an int8 from r.

func (ReadCloser) ReadUint16

func (r ReadCloser) ReadUint16() (uint16, error)

ReadUint16 reads a uint16 from r.

func (ReadCloser) ReadUint32

func (r ReadCloser) ReadUint32() (uint32, error)

ReadUint32 reads a uint32 from r.

func (ReadCloser) ReadUint64

func (r ReadCloser) ReadUint64() (uint64, error)

ReadUint64 reads a uint64 from r.

func (ReadCloser) ReadUint8

func (r ReadCloser) ReadUint8() (uint8, error)

ReadUint8 reads a uint8 from r.

type ReadWriteCloser

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

ReadWriteCloser wraps an io.ReadWriteCloser and implements BinaryReader and BinaryWriter.

func NewReadWriteCloser

func NewReadWriteCloser(rw io.ReadWriteCloser, e binary.ByteOrder) *ReadWriteCloser

NewReadWriteCloser wraps the given io.ReadWriteCloser as a BinaryReader and BinaryWriter using the given byte order.

func (*ReadWriteCloser) ByteOrder

func (rw *ReadWriteCloser) ByteOrder() binary.ByteOrder

ByteOrder returns the byte order used.

func (*ReadWriteCloser) Close

func (rw *ReadWriteCloser) Close() error

Close closes the underlying writer.

func (ReadWriteCloser) Read

func (r ReadWriteCloser) Read(b []byte) (int, error)

Read reads data from r.

func (ReadWriteCloser) ReadByte

func (r ReadWriteCloser) ReadByte() (byte, error)

ReadByte reads a byte from r.

func (ReadWriteCloser) ReadInt16

func (r ReadWriteCloser) ReadInt16() (int16, error)

ReadInt16 reads an int16 from r.

func (ReadWriteCloser) ReadInt32

func (r ReadWriteCloser) ReadInt32() (int32, error)

ReadInt32 reads an int32 from r.

func (ReadWriteCloser) ReadInt64

func (r ReadWriteCloser) ReadInt64() (int64, error)

ReadInt64 reads an int64 from r.

func (ReadWriteCloser) ReadInt8

func (r ReadWriteCloser) ReadInt8() (int8, error)

ReadInt8 reads an int8 from r.

func (ReadWriteCloser) ReadUint16

func (r ReadWriteCloser) ReadUint16() (uint16, error)

ReadUint16 reads a uint16 from r.

func (ReadWriteCloser) ReadUint32

func (r ReadWriteCloser) ReadUint32() (uint32, error)

ReadUint32 reads a uint32 from r.

func (ReadWriteCloser) ReadUint64

func (r ReadWriteCloser) ReadUint64() (uint64, error)

ReadUint64 reads a uint64 from r.

func (ReadWriteCloser) ReadUint8

func (r ReadWriteCloser) ReadUint8() (uint8, error)

ReadUint8 reads a uint8 from r.

func (ReadWriteCloser) Write

func (w ReadWriteCloser) Write(b []byte) (int, error)

Write writes data to w.

func (ReadWriteCloser) WriteByte

func (w ReadWriteCloser) WriteByte(b byte) error

WriteByte write the byte b to w.

func (ReadWriteCloser) WriteInt16

func (w ReadWriteCloser) WriteInt16(m int16) error

WriteInt16 writes an int16 to w.

func (ReadWriteCloser) WriteInt32

func (w ReadWriteCloser) WriteInt32(m int32) error

WriteInt32 writes an int32 to w.

func (ReadWriteCloser) WriteInt64

func (w ReadWriteCloser) WriteInt64(m int64) error

WriteInt64 writes an int64 to w.

func (ReadWriteCloser) WriteInt8

func (w ReadWriteCloser) WriteInt8(m int8) error

WriteInt8 writes an int8 to w.

func (ReadWriteCloser) WriteUint16

func (w ReadWriteCloser) WriteUint16(m uint16) error

WriteUint16 writes a uint16 to w.

func (ReadWriteCloser) WriteUint32

func (w ReadWriteCloser) WriteUint32(m uint32) error

WriteUint32 writes a uint32 to w.

func (ReadWriteCloser) WriteUint64

func (w ReadWriteCloser) WriteUint64(m uint64) error

WriteUint64 writes a uint64 to w.

func (ReadWriteCloser) WriteUint8

func (w ReadWriteCloser) WriteUint8(m uint8) error

WriteUint8 writes a uint8 to w

type ReadWriter

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

ReadWriter wraps an io.ReadWriter and implements BinaryReader and BinaryWriter.

func NewReadWriter

func NewReadWriter(rw io.ReadWriter, e binary.ByteOrder) *ReadWriter

NewReadWriter wraps the given io.ReadWriter as a BinaryReader and BinaryWriter using the given byte order.

func (*ReadWriter) ByteOrder

func (rw *ReadWriter) ByteOrder() binary.ByteOrder

ByteOrder returns the byte order used.

func (ReadWriter) Read

func (r ReadWriter) Read(b []byte) (int, error)

Read reads data from r.

func (ReadWriter) ReadByte

func (r ReadWriter) ReadByte() (byte, error)

ReadByte reads a byte from r.

func (ReadWriter) ReadInt16

func (r ReadWriter) ReadInt16() (int16, error)

ReadInt16 reads an int16 from r.

func (ReadWriter) ReadInt32

func (r ReadWriter) ReadInt32() (int32, error)

ReadInt32 reads an int32 from r.

func (ReadWriter) ReadInt64

func (r ReadWriter) ReadInt64() (int64, error)

ReadInt64 reads an int64 from r.

func (ReadWriter) ReadInt8

func (r ReadWriter) ReadInt8() (int8, error)

ReadInt8 reads an int8 from r.

func (ReadWriter) ReadUint16

func (r ReadWriter) ReadUint16() (uint16, error)

ReadUint16 reads a uint16 from r.

func (ReadWriter) ReadUint32

func (r ReadWriter) ReadUint32() (uint32, error)

ReadUint32 reads a uint32 from r.

func (ReadWriter) ReadUint64

func (r ReadWriter) ReadUint64() (uint64, error)

ReadUint64 reads a uint64 from r.

func (ReadWriter) ReadUint8

func (r ReadWriter) ReadUint8() (uint8, error)

ReadUint8 reads a uint8 from r.

func (ReadWriter) Write

func (w ReadWriter) Write(b []byte) (int, error)

Write writes data to w.

func (ReadWriter) WriteByte

func (w ReadWriter) WriteByte(b byte) error

WriteByte write the byte b to w.

func (ReadWriter) WriteInt16

func (w ReadWriter) WriteInt16(m int16) error

WriteInt16 writes an int16 to w.

func (ReadWriter) WriteInt32

func (w ReadWriter) WriteInt32(m int32) error

WriteInt32 writes an int32 to w.

func (ReadWriter) WriteInt64

func (w ReadWriter) WriteInt64(m int64) error

WriteInt64 writes an int64 to w.

func (ReadWriter) WriteInt8

func (w ReadWriter) WriteInt8(m int8) error

WriteInt8 writes an int8 to w.

func (ReadWriter) WriteUint16

func (w ReadWriter) WriteUint16(m uint16) error

WriteUint16 writes a uint16 to w.

func (ReadWriter) WriteUint32

func (w ReadWriter) WriteUint32(m uint32) error

WriteUint32 writes a uint32 to w.

func (ReadWriter) WriteUint64

func (w ReadWriter) WriteUint64(m uint64) error

WriteUint64 writes a uint64 to w.

func (ReadWriter) WriteUint8

func (w ReadWriter) WriteUint8(m uint8) error

WriteUint8 writes a uint8 to w

type Reader

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

Reader wraps an io.Reader and implements BinaryReader.

func NewReader

func NewReader(r io.Reader, e binary.ByteOrder) *Reader

NewReader wraps the given io.Reader as a BinaryReader using the given byte order.

func (*Reader) ByteOrder

func (r *Reader) ByteOrder() binary.ByteOrder

ByteOrder returns the byte order used.

func (Reader) Read

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

Read reads data from r.

func (Reader) ReadByte

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

ReadByte reads a byte from r.

func (Reader) ReadInt16

func (r Reader) ReadInt16() (int16, error)

ReadInt16 reads an int16 from r.

func (Reader) ReadInt32

func (r Reader) ReadInt32() (int32, error)

ReadInt32 reads an int32 from r.

func (Reader) ReadInt64

func (r Reader) ReadInt64() (int64, error)

ReadInt64 reads an int64 from r.

func (Reader) ReadInt8

func (r Reader) ReadInt8() (int8, error)

ReadInt8 reads an int8 from r.

func (Reader) ReadUint16

func (r Reader) ReadUint16() (uint16, error)

ReadUint16 reads a uint16 from r.

func (Reader) ReadUint32

func (r Reader) ReadUint32() (uint32, error)

ReadUint32 reads a uint32 from r.

func (Reader) ReadUint64

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

ReadUint64 reads a uint64 from r.

func (Reader) ReadUint8

func (r Reader) ReadUint8() (uint8, error)

ReadUint8 reads a uint8 from r.

type WriteCloser

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

WriteCloser wraps an io.WriteCloser and implements BinaryWriter.

func NewWriteCloser

func NewWriteCloser(w io.WriteCloser, e binary.ByteOrder) *WriteCloser

NewWriteCloser wraps the given io.WriteCloser as a BinaryWriter using the given byte order.

func (*WriteCloser) ByteOrder

func (w *WriteCloser) ByteOrder() binary.ByteOrder

ByteOrder returns the byte order used.

func (*WriteCloser) Close

func (w *WriteCloser) Close() error

Close closes the underlying writer.

func (WriteCloser) Write

func (w WriteCloser) Write(b []byte) (int, error)

Write writes data to w.

func (WriteCloser) WriteByte

func (w WriteCloser) WriteByte(b byte) error

WriteByte write the byte b to w.

func (WriteCloser) WriteInt16

func (w WriteCloser) WriteInt16(m int16) error

WriteInt16 writes an int16 to w.

func (WriteCloser) WriteInt32

func (w WriteCloser) WriteInt32(m int32) error

WriteInt32 writes an int32 to w.

func (WriteCloser) WriteInt64

func (w WriteCloser) WriteInt64(m int64) error

WriteInt64 writes an int64 to w.

func (WriteCloser) WriteInt8

func (w WriteCloser) WriteInt8(m int8) error

WriteInt8 writes an int8 to w.

func (WriteCloser) WriteUint16

func (w WriteCloser) WriteUint16(m uint16) error

WriteUint16 writes a uint16 to w.

func (WriteCloser) WriteUint32

func (w WriteCloser) WriteUint32(m uint32) error

WriteUint32 writes a uint32 to w.

func (WriteCloser) WriteUint64

func (w WriteCloser) WriteUint64(m uint64) error

WriteUint64 writes a uint64 to w.

func (WriteCloser) WriteUint8

func (w WriteCloser) WriteUint8(m uint8) error

WriteUint8 writes a uint8 to w

type Writer

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

Writer wraps an io.Writer and implements BinaryWriter.

func NewWriter

func NewWriter(w io.Writer, e binary.ByteOrder) *Writer

NewWriter wraps the given io.Writer as a BinaryWriter using the given byte order.

func (*Writer) ByteOrder

func (w *Writer) ByteOrder() binary.ByteOrder

ByteOrder returns the byte order used.

func (Writer) Write

func (w Writer) Write(b []byte) (int, error)

Write writes data to w.

func (Writer) WriteByte

func (w Writer) WriteByte(b byte) error

WriteByte write the byte b to w.

func (Writer) WriteInt16

func (w Writer) WriteInt16(m int16) error

WriteInt16 writes an int16 to w.

func (Writer) WriteInt32

func (w Writer) WriteInt32(m int32) error

WriteInt32 writes an int32 to w.

func (Writer) WriteInt64

func (w Writer) WriteInt64(m int64) error

WriteInt64 writes an int64 to w.

func (Writer) WriteInt8

func (w Writer) WriteInt8(m int8) error

WriteInt8 writes an int8 to w.

func (Writer) WriteUint16

func (w Writer) WriteUint16(m uint16) error

WriteUint16 writes a uint16 to w.

func (Writer) WriteUint32

func (w Writer) WriteUint32(m uint32) error

WriteUint32 writes a uint32 to w.

func (Writer) WriteUint64

func (w Writer) WriteUint64(m uint64) error

WriteUint64 writes a uint64 to w.

func (Writer) WriteUint8

func (w Writer) WriteUint8(m uint8) error

WriteUint8 writes a uint8 to w

Jump to

Keyboard shortcuts

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