aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/serve-protocol.hh
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-05-18 02:35:34 +0200
committereldritch horrors <pennae@lix.systems>2024-07-16 00:57:42 +0000
commita5d1f698417dff4e470eb94c38ad6c4e5ebf38ff (patch)
tree116b887a80fd96f9008bc55c872a24ef1955ca2f /src/libstore/serve-protocol.hh
parent5271424d14241ec5cbe7ab3bda85ddeb486cff76 (diff)
libstore: generatorize protocol serializers
this is cursed. deeply and profoundly cursed. under NO CIRCUMSTANCES must protocol serializer helpers be applied to temporaries! doing so will inevitably cause dangling references and cause the entire thing to crash. we need to do this even so to get rid of boost coroutines, and likewise to encapsulate the serializers we suffer today at least a little bit to allow a gradual migration to an actual IPC protocol. (this isn't a problem that's unique to generators. c++ coroutines in general cannot safely take references to arbitrary temporaries since c++ does not have a lifetime system that can make this safe. -sigh-) Change-Id: I2921ba451e04d86798752d140885d3c5cc08e146
Diffstat (limited to 'src/libstore/serve-protocol.hh')
-rw-r--r--src/libstore/serve-protocol.hh9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/libstore/serve-protocol.hh b/src/libstore/serve-protocol.hh
index 742320933..34c591a24 100644
--- a/src/libstore/serve-protocol.hh
+++ b/src/libstore/serve-protocol.hh
@@ -79,7 +79,7 @@ struct ServeProto
#if 0
{
static T read(const Store & store, ReadConn conn);
- static void write(const Store & store, WriteConn conn, const T & t);
+ static WireFormatGenerator write(const Store & store, WriteConn conn, const T & t);
};
#endif
@@ -88,9 +88,10 @@ struct ServeProto
* infer the type instead of having to write it down explicitly.
*/
template<typename T>
- static void write(const Store & store, WriteConn conn, const T & t)
+ [[nodiscard]]
+ static WireFormatGenerator write(const Store & store, WriteConn conn, const T & t)
{
- ServeProto::Serialise<T>::write(store, conn, t);
+ return ServeProto::Serialise<T>::write(store, conn, t);
}
};
@@ -142,7 +143,7 @@ inline std::ostream & operator << (std::ostream & s, ServeProto::Command op)
struct ServeProto::Serialise< T > \
{ \
static T read(const Store & store, ServeProto::ReadConn conn); \
- static void write(const Store & store, ServeProto::WriteConn conn, const T & t); \
+ [[nodiscard]] static WireFormatGenerator write(const Store & store, ServeProto::WriteConn conn, const T & t); \
};
template<>