Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
msgpack_impl.hpp
Go to the documentation of this file.
1
#pragma once
2
// Meant to be the main header included by *.cpp files* that use msgpack.
3
// Note: heavy header due to serialization logic, don't include if msgpack.hpp will do
4
5
#include <cstring>
6
7
#include "
barretenberg/common/mem.hpp
"
8
9
#include "
barretenberg/common/try_catch_shim.hpp
"
10
#include "
msgpack_impl/check_memory_span.hpp
"
11
#include "
msgpack_impl/concepts.hpp
"
12
#include "
msgpack_impl/msgpack_impl.hpp
"
13
#include "
msgpack_impl/name_value_pair_macro.hpp
"
14
#include "
msgpack_impl/schema_name.hpp
"
15
#include "
msgpack_impl/struct_map_impl.hpp
"
16
24
inline
std::pair<uint8_t*, size_t>
msgpack_encode_buffer
(
auto
&& obj,
25
uint8_t* scratch_buf =
nullptr
,
26
size_t
scratch_size = 0)
27
{
28
// Create a buffer to store the encoded data
29
msgpack::sbuffer
buffer
;
30
msgpack::pack(
buffer
, obj);
31
32
// If scratch buffer provided and result fits, use it
33
if
(scratch_buf !=
nullptr
&&
buffer
.size() <= scratch_size) {
34
memcpy(scratch_buf,
buffer
.data(),
buffer
.size());
35
return
{ scratch_buf,
buffer
.size() };
36
}
37
38
// Otherwise allocate new buffer
39
uint8_t* output =
static_cast<
uint8_t*
>
(aligned_alloc(64,
buffer
.size()));
40
memcpy(output,
buffer
.data(),
buffer
.size());
41
return
{ output,
buffer
.size() };
42
}
check_memory_span.hpp
concepts.hpp
buffer
std::unique_ptr< uint8_t[]> buffer
Definition
engine.cpp:60
mem.hpp
msgpack_impl.hpp
msgpack_encode_buffer
std::pair< uint8_t *, size_t > msgpack_encode_buffer(auto &&obj, uint8_t *scratch_buf=nullptr, size_t scratch_size=0)
Definition
msgpack_impl.hpp:24
name_value_pair_macro.hpp
std::get
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition
tuple.hpp:13
schema_name.hpp
struct_map_impl.hpp
try_catch_shim.hpp
src
barretenberg
serialize
msgpack_impl.hpp
Generated by
1.9.8