pack

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package pack provides helpers to pack bytes and strings into []uint64 slices.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes

func Bytes(data []byte) []uint64

Bytes packs a byte slice into a uint64 slice. If the length of the byte slice is not a multiple of 8, it will pad the remaining bytes with zeroes.

func BytesInto added in v0.4.9

func BytesInto(data []byte, out []uint64)

BytesInto packs a byte slice into the given pre-allocated uint64 slice. The output slice should have length >=[BytesPackedLength](data).

func BytesInv

func BytesInv(data []uint64, originalLength int) []byte

BytesInv unpacks a []uint64 slice as packed by Bytes,

func BytesInvInto added in v0.5.0

func BytesInvInto(data []uint64, out []byte)

BytesInvInto unpacks a []uint64 slice as packed by Bytes into the given byte slice.

func BytesPackedLength added in v0.4.9

func BytesPackedLength(data []byte) int

BytesPackedLength return the packed length of the given byte slice.

func ReallocateFlat added in v0.4.9

func ReallocateFlat[T any](d [][]T)

ReallocateFlat re-allocates the given 2d slice with a flat backing slice.

func String

func String(data string) []uint64

String packs a string into a uint64 slice. If the length of the string in bytes is not a multiple of 8, it will pad the remaining bytes with zeroes.

func StringInto added in v0.4.9

func StringInto(data string, out []uint64)

String packs a string into the given pre-allocated uint64 slice. The output slice should have length >=[StringPackedLength](data).

func StringInv

func StringInv(data []uint64, originalLengthBytes int) string

StringInv unpacks a []uint64 slice as packed by String,

func StringPackedLength added in v0.4.9

func StringPackedLength(data string) int

StringPackedLength return the packed length of the given byte slice.

Types

This section is empty.

Jump to

Keyboard shortcuts

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