parselink-old/include/parselink/proto/session_id.h

50 lines
1.5 KiB
C++

//-----------------------------------------------------------------------------
// ___ __ _ _
// / _ \__ _ _ __ ___ ___ / /(_)_ __ | | __
// / /_)/ _` | '__/ __|/ _ \/ / | | '_ \| |/ /
// / ___/ (_| | | \__ \ __/ /__| | | | | <
// \/ \__,_|_| |___/\___\____/_|_| |_|_|\_\ .
//
//-----------------------------------------------------------------------------
// Author: Kurt Sassenrath
// Module: proto
//
// Session ID. Used as a handle to access an existing user session, which can
// also be used to share parse data without any linking of users.
//
// Copyright (c) 2023 Kurt Sassenrath.
//
// License TBD.
//-----------------------------------------------------------------------------
#ifndef session_id_6598f9bae1cbb501
#define session_id_6598f9bae1cbb501
#include <array>
#include <cstddef>
#include <span>
namespace parselink {
namespace proto {
struct session_id {
std::array<std::byte, 32> bytes;
session_id() noexcept;
[[nodiscard]] constexpr auto operator<=>(
session_id const& other) const noexcept {
return bytes <=> other.bytes;
}
[[nodiscard]] constexpr auto operator<=>(
std::span<std::byte const> other) const noexcept {
return std::lexicographical_compare_three_way(bytes.begin(),
bytes.end(), other.begin(), other.end(),
std::compare_three_way());
}
};
} // namespace proto
} // namespace parselink
#endif // session_id_6598f9bae1cbb501