Documentation
¶
Overview ¶
Package dpuid packs same-sign integer sequences into UUID-compatible Delta-Pack UUID values and unpacks them back to absolute-value sorted slices.
Index ¶
- Variables
- func Pack(values []int64) (uuid.UUID, 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 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") ErrPayloadOverflow = errors.New("dpuid: payload exceeds input size") ErrValueOverflow = errors.New("dpuid: value overflows target integer type") )
Functions ¶
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 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.