// Copyright (c) 2025 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef MP_PROXY_TYPE_CHRONO_H #define MP_PROXY_TYPE_CHRONO_H #include #include namespace mp { //! Overload CustomBuildField and CustomReadField to serialize std::chrono //! parameters and return values as numbers. template void CustomBuildField(TypeList>, Priority<1>, InvokeContext& invoke_context, Value&& value, Output&& output) { static_assert(std::numeric_limits::lowest() <= std::numeric_limits::lowest(), "capnp type does not have enough range to hold lowest std::chrono::duration value"); static_assert(std::numeric_limits::max() >= std::numeric_limits::max(), "capnp type does not have enough range to hold highest std::chrono::duration value"); output.set(value.count()); } template decltype(auto) CustomReadField(TypeList>, Priority<1>, InvokeContext& invoke_context, Input&& input, ReadDest&& read_dest) { return read_dest.construct(input.get()); } } // namespace mp #endif // MP_PROXY_TYPE_CHRONO_H