lokinet/llarp/router_id.hpp

64 lines
1.0 KiB
C++
Raw Normal View History

2018-06-10 14:05:48 +00:00
#ifndef LLARP_ROUTER_ID_HPP
#define LLARP_ROUTER_ID_HPP
#include <util/aligned.hpp>
2019-02-11 17:14:43 +00:00
#include <util/status.hpp>
2018-06-10 14:05:48 +00:00
namespace llarp
{
struct RouterID : public AlignedBuffer<32>
{
static constexpr size_t SIZE = 32;
using Data = std::array<byte_t, SIZE>;
2019-08-26 23:29:17 +00:00
RouterID()
{
}
RouterID(const byte_t* buf) : AlignedBuffer<SIZE>(buf)
{
}
RouterID(const Data& data) : AlignedBuffer<SIZE>(data)
{
}
2019-02-11 17:14:43 +00:00
util::StatusObject
2019-04-19 15:10:26 +00:00
ExtractStatus() const;
2019-02-11 17:14:43 +00:00
std::string
ToString() const;
2020-03-01 00:26:23 +00:00
std::string
ShortString() const;
bool
FromString(std::string_view str);
RouterID&
operator=(const byte_t* ptr)
{
std::copy(ptr, ptr + SIZE, begin());
return *this;
}
friend std::ostream&
operator<<(std::ostream& out, const RouterID& id)
{
return out << id.ToString();
}
using Hash = AlignedBuffer<SIZE>::Hash;
};
2019-01-22 23:50:26 +00:00
inline bool
operator==(const RouterID& lhs, const RouterID& rhs)
{
return lhs.as_array() == rhs.as_array();
}
} // namespace llarp
2018-06-10 14:05:48 +00:00
#endif