5#ifndef BITCOIN_IPC_CAPNP_COMMON_TYPES_H
6#define BITCOIN_IPC_CAPNP_COMMON_TYPES_H
16#include <mp/proxy-types.h>
17#include <mp/type-chrono.h>
18#include <mp/type-context.h>
19#include <mp/type-data.h>
20#include <mp/type-decay.h>
21#include <mp/type-interface.h>
22#include <mp/type-message.h>
23#include <mp/type-number.h>
24#include <mp/type-optional.h>
25#include <mp/type-pointer.h>
26#include <mp/type-string.h>
27#include <mp/type-struct.h>
28#include <mp/type-threadmap.h>
29#include <mp/type-vector.h>
52concept Deserializable = std::is_constructible_v<T, ::deserialize_type, ::DataStream&>;
62template <
typename LocalType,
typename Value,
typename Output>
63void CustomBuildField(TypeList<LocalType>, Priority<1>, InvokeContext& invoke_context, Value&& value, Output&& output)
73 value.Serialize(wrapper);
74 auto result = output.init(stream.
size());
75 memcpy(result.begin(), stream.
data(), stream.
size());
82template <
typename LocalType,
typename Input,
typename ReadDest>
83decltype(
auto)
CustomReadField(TypeList<LocalType>, Priority<1>, InvokeContext& invoke_context, Input&& input, ReadDest&& read_dest)
86 return read_dest.update([&](
auto& value) {
87 if (!input.has())
return;
88 auto data = input.get();
91 value.Unserialize(wrapper);
99template <
typename LocalType,
typename Input,
typename ReadDest>
100decltype(
auto)
CustomReadField(TypeList<LocalType>, Priority<1>, InvokeContext& invoke_context, Input&& input, ReadDest&& read_dest)
104 auto data = input.get();
112template <
typename Value,
typename Output>
113void CustomBuildField(TypeList<UniValue>, Priority<1>, InvokeContext& invoke_context, Value&& value, Output&& output)
115 std::string str = value.write();
116 auto result = output.init(str.size());
117 memcpy(result.begin(), str.data(), str.size());
120template <
typename Input,
typename ReadDest>
121decltype(
auto)
CustomReadField(TypeList<UniValue>, Priority<1>, InvokeContext& invoke_context, Input&& input,
122 ReadDest&& read_dest)
124 return read_dest.update([&](
auto& value) {
125 auto data = input.get();
126 value.read(std::string_view{
data.begin(),
data.size()});
Double ended buffer combining vector and stream-like interfaces.
Wrapper that overrides the GetParams() function of a stream.
Minimal stream for reading from an existing byte array by Span.
If none of the specialized versions above matched, default to calling member function.
Detect if type has a deserialize_type constructor, which is used to deserialize types like CTransacti...
auto Wrap(S &s)
Construct a ParamStream wrapping a data stream with serialization parameters needed to pass transacti...
Functions to serialize / deserialize common bitcoin types.
decltype(auto) CustomReadField(TypeList< LocalType >, Priority< 1 >, InvokeContext &invoke_context, Input &&input, ReadDest &&read_dest)
Overload multiprocess library's CustomReadField hook to allow any object with an Unserialize method t...
void CustomBuildField(TypeList< LocalType >, Priority< 1 >, InvokeContext &invoke_context, Value &&value, Output &&output)
Overload multiprocess library's CustomBuildField hook to allow any serializable object to be stored i...
#define S(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)
static constexpr TransactionSerParams TX_WITH_WITNESS
constexpr deserialize_type deserialize