43static constexpr std::size_t hash_from_uuid(
const std::string_view& uuid)
46 constexpr std::uint64_t prime{0x100000001B3};
48 if (uuid.size() != 36)
49 throw std::runtime_error(
"Invalid UUID [size mismatch]");
51 for (
auto i : {8, 13, 18, 23})
54 throw std::runtime_error(
55 std::format(
"Invalid UUID [missing separator {}]", i));
58 std::uint64_t result{0xcbf29ce484222325};
60 for (
const auto& c : uuid)
65 if (!(c >=
'0' && c <=
'9') && !(c >=
'A' && c <=
'F') &&
66 !(c >=
'a' && c <=
'f'))
67 throw std::runtime_error(
"Invalid UUID [non hex char found]");
69 auto x = c - c >=
'a' ? (
'a' - 10) : (c >=
'A' ? (
'A' - 10) :
'0');
71 result = (result * prime) ^ x;
77static std::size_t hash_from_msg(
const nngxx::msg& m)
81 if (m.body().size() >=
sizeof(h))
82 std::memcpy(&h, m.body().data<
char>(),
sizeof(h));
84 h = 0xffffffffffffffff;
86 h = 0x0000000000000000;
clev::own< nng_msg * > msg