Documentation
¶
Overview ¶
Package dpuid packs same-sign integer sequences into Delta-Pack UUID byte, base64, or UUID values and unpacks them into absolute-value sorted slices.
Index ¶
- Variables
- func Pack(values []int64) (uuid.UUID, error)
- func PackBase64[T Integer](values []T) (string, error)
- func PackBase64Bits[T Integer](values []T, outputBits int) (string, error)
- func PackBytes[T Integer](values []T, outputBits int) ([]byte, error)
- func PackMode(values []int64, mode Mode) (uuid.UUID, error)
- func PackValues[T Integer](values []T) (uuid.UUID, error)
- func PackValuesMode[T Integer](values []T, mode Mode) (uuid.UUID, error)
- func Unpack(id uuid.UUID) ([]int64, error)
- func UnpackBase64[T Integer](value string) ([]T, error)
- func UnpackBase64Bits[T Integer](value string, inputBits int) ([]T, error)
- func UnpackBytes[T Integer](data []byte, inputBits int) ([]T, error)
- func UnpackMode(id uuid.UUID, mode Mode) ([]int64, error)
- func UnpackValues[T Integer](id uuid.UUID) ([]T, error)
- func UnpackValuesMode[T Integer](id uuid.UUID, mode Mode) ([]T, error)
- type Integer
- type Mode
Constants ¶
This section is empty.
Variables ¶
var ( ErrEmptyInput = errors.New("dpuid: empty input") ErrMixedSigns = errors.New("dpuid: mixed signs") ErrDeltaOverflow = errors.New("dpuid: max delta too large") ErrCountOverflow = errors.New("dpuid: too many numbers") ErrTotalOverflow = errors.New("dpuid: encoded payload exceeds output size") ErrInvalidMode = errors.New("dpuid: invalid mode") ErrInvalidUUIDv8 = errors.New("dpuid: invalid UUIDv8 markers") ErrInvalidBase64 = errors.New("dpuid: invalid base64") ErrInvalidBitLimit = errors.New("dpuid: invalid bit limit") ErrPayloadOverflow = errors.New("dpuid: payload exceeds input size") ErrValueOverflow = errors.New("dpuid: value overflows target integer type") )
Functions ¶
func PackBase64 ¶ added in v1.1.0
PackBase64 encodes values into a variable-length RFC 4648 base64 string.
func PackBase64Bits ¶ added in v1.1.0
PackBase64Bits encodes values into base64 using the requested payload size. A zero outputBits value selects the minimum byte-aligned payload size.
func PackBytes ¶ added in v1.1.0
PackBytes encodes values into an MSB-first DPUID payload. A zero outputBits value selects a variable-length byte-aligned payload; a positive value sets the exact usable bit limit.
func PackMode ¶
PackMode encodes values according to SPEC.md.
The input order is not preserved. Decoding returns values sorted ascending by absolute value. Values must be sign-homogeneous: all non-negative or all non-positive.
func PackValues ¶
PackValues encodes signed or unsigned integer values in UUIDv8 mode.
func PackValuesMode ¶
PackValuesMode encodes signed or unsigned integer values according to SPEC.md.
func UnpackBase64 ¶ added in v1.1.0
UnpackBase64 decodes a variable-length RFC 4648 base64 DPUID payload.
func UnpackBase64Bits ¶ added in v1.1.0
UnpackBase64Bits decodes a base64 DPUID payload with the requested bit size. A zero inputBits value selects the variable-length byte-aligned layout.
func UnpackBytes ¶ added in v1.1.0
UnpackBytes decodes an MSB-first DPUID payload. A zero inputBits value selects the variable-length byte-aligned layout; a positive value is the exact usable bit limit and must match the supplied buffer size.
func UnpackMode ¶
UnpackMode decodes a DPUID value encoded in the selected mode.
func UnpackValues ¶
UnpackValues decodes a UUIDv8 DPUID value into the requested integer type.
Types ¶
type Integer ¶
type Integer interface {
~int | ~int8 | ~int16 | ~int32 | ~int64 |
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64
}
Integer is any built-in signed or unsigned integer type up to 64 bits.