bnry

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: MIT Imports: 9 Imported by: 1

Documentation

Overview

Package bnry provides simple functions for encoding and decoding values as binary.

Supported data types

The types that can be encoded and decoded are int*, uint* (excluding int and uint), float*, bool, string and slices of these types. Read and UnmarshalBinary expect pointers to these types, while Write and MarshalBinary expect non-pointers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalBinary

func MarshalBinary(vals ...any) []byte

MarshalBinary writes the given values to a byte slice. Values should be of any of the supported types. Panics if a value is of an unsupported type.

func Read

func Read(r io.ByteReader, vals ...any) error

Read reads and decodes binary data into the given values. Values should be pointers to any of the supported types. Panics if a value is of an unsupported type.

func UnmarshalBinary

func UnmarshalBinary(data []byte, vals ...any) error

UnmarshalBinary decodes binary data into the given values. Values should be pointers to any of the supported types. Panics if a value is of an unsupported type.

func Write

func Write(w io.Writer, vals ...any) error

Write writes the given values to the given writer. Values should be of any of the supported types. Panics if a value is of an unsupported type.

Types

type Writer added in v0.1.17

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

func NewWriter added in v0.1.17

func NewWriter(w io.Writer) *Writer

func (*Writer) Write added in v0.1.17

func (w *Writer) Write(vals ...any) error

Write writes the given values. Values should be of any of the supported types. Panics if a value is of an unsupported type.

Jump to

Keyboard shortcuts

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