libstore: add CommonProto code for bool/unsigned/uint64_t
we will need these very soon to make the daemon wires more rpc-like. Change-Id: Ib54acdff0899d70a4c9b1d00c144932c37fdff91
This commit is contained in:
@@ -10,6 +10,38 @@ namespace nix {
|
||||
|
||||
/* protocol-agnostic definitions */
|
||||
|
||||
bool CommonProto::Serialise<bool>::read(CommonProto::ReadConn conn)
|
||||
{
|
||||
return readNum<uint64_t>(conn.from);
|
||||
}
|
||||
|
||||
WireFormatGenerator CommonProto::Serialise<bool>::write(CommonProto::WriteConn conn, const bool & b)
|
||||
{
|
||||
co_yield b;
|
||||
}
|
||||
|
||||
unsigned CommonProto::Serialise<unsigned>::read(CommonProto::ReadConn conn)
|
||||
{
|
||||
return readNum<unsigned>(conn.from);
|
||||
}
|
||||
|
||||
WireFormatGenerator
|
||||
CommonProto::Serialise<unsigned>::write(CommonProto::WriteConn conn, const unsigned & u)
|
||||
{
|
||||
co_yield u;
|
||||
}
|
||||
|
||||
uint64_t CommonProto::Serialise<uint64_t>::read(CommonProto::ReadConn conn)
|
||||
{
|
||||
return readNum<uint64_t>(conn.from);
|
||||
}
|
||||
|
||||
WireFormatGenerator
|
||||
CommonProto::Serialise<uint64_t>::write(CommonProto::WriteConn conn, const uint64_t & u)
|
||||
{
|
||||
co_yield u;
|
||||
}
|
||||
|
||||
std::string CommonProto::Serialise<std::string>::read(CommonProto::ReadConn conn)
|
||||
{
|
||||
return readString(conn.from);
|
||||
|
||||
@@ -63,6 +63,12 @@ struct CommonProto
|
||||
[[nodiscard]] static WireFormatGenerator write(CommonProto::WriteConn conn, const T & str); \
|
||||
}
|
||||
|
||||
template<>
|
||||
DECLARE_COMMON_SERIALISER(bool);
|
||||
template<>
|
||||
DECLARE_COMMON_SERIALISER(unsigned);
|
||||
template<>
|
||||
DECLARE_COMMON_SERIALISER(uint64_t);
|
||||
template<>
|
||||
DECLARE_COMMON_SERIALISER(std::string);
|
||||
template<>
|
||||
|
||||
Reference in New Issue
Block a user