package transcoder

import (
	"encoding/binary"

	"github.com/google/uuid"
)

// uuidToHiLo splits a 16-byte UUID into the two big-endian uint64
// halves used by the FlatBuffers `common.UUID` struct (`hi` carries
// bytes 0..7, `lo` carries bytes 8..15).
func uuidToHiLo(value uuid.UUID) (uint64, uint64) {
	return binary.BigEndian.Uint64(value[0:8]), binary.BigEndian.Uint64(value[8:16])
}

// uuidFromHiLo reverses uuidToHiLo.
func uuidFromHiLo(hi, lo uint64) uuid.UUID {
	var value uuid.UUID
	binary.BigEndian.PutUint64(value[0:8], hi)
	binary.BigEndian.PutUint64(value[8:16], lo)
	return value
}
