14#include <shared_mutex>
18#include <parcel/parcel.h>
35 auto reg = std::make_shared<parcel::ParcelRegistry>();
37 registry_ = std::move(reg);
41 const auto snap = other.snapshot();
42 registry_ = std::make_shared<parcel::ParcelRegistry>(*snap);
62 const auto current = snapshot();
63 auto next = std::make_shared<parcel::ParcelRegistry>(*current);
64 next->register_kind(std::move(desc));
65 std::unique_lock lock(mu_);
66 registry_ = std::move(next);
71 const auto reg = snapshot();
74 const auto env = parcel::cell_cast<EventEnvelope>(cell);
76 }
catch (
const parcel::ParcelException& e) {
83 const auto j = parcel::json_t::from_cbor(bytes);
85 }
catch (
const parcel::ParcelException& e) {
89 }
catch (
const std::exception& e) {
96 const auto j = parcel::json_t::from_cbor(bytes);
98 }
catch (
const parcel::ParcelException& e) {
102 }
catch (
const std::exception& e) {
110 [[nodiscard]] std::shared_ptr<const parcel::ParcelRegistry>
116 [[nodiscard]] std::shared_ptr<parcel::ParcelRegistry> snapshot()
const {
117 std::shared_lock lock(mu_);
121 mutable std::shared_mutex mu_;
122 std::shared_ptr<parcel::ParcelRegistry> registry_;
130 std::vector<char> out;
131 parcel::json_t::to_cbor(env.
to_json(), out);
135namespace serialization {
141using ::conduit::encode_cbor;
142using ::conduit::encode_json;
Polymorphic envelope cell.
Definition envelope.hpp:62
parcel::json_t to_json() const override
Definition envelope.hpp:194
static parcel::cell_t from_json(parcel::json_t const &j, parcel::ParcelRegistry const ®)
Definition envelope.hpp:246
Registers event cells for wire decoding.
Definition serialization.hpp:32
EventEnvelope decode_cbor(std::span< const std::uint8_t > bytes) const
Definition serialization.hpp:81
EventRegistry()
Definition serialization.hpp:34
EventRegistry(EventRegistry &&) noexcept=delete
EventRegistry(const EventRegistry &other)
Definition serialization.hpp:40
EventRegistry & add()
Register the descriptor for an event type T (i.e.
Definition serialization.hpp:53
EventRegistry & add_descriptor(parcel::cell_type_descriptor_t desc)
Register a previously-resolved cell descriptor.
Definition serialization.hpp:61
EventEnvelope decode_cbor(std::span< const char > bytes) const
Definition serialization.hpp:94
EventEnvelope decode_json(parcel::json_t const &j) const
Definition serialization.hpp:70
std::shared_ptr< const parcel::ParcelRegistry > parcel_registry_snapshot() const noexcept
Snapshot accessor for the underlying parcel registry.
Definition serialization.hpp:111
Raised by envelope/cell deserialization when the wire data is malformed.
Definition exception.hpp:56
EventEnvelope — a parcel cell carrying conduit's envelope metadata plus a polymorphic payload cell.
Event<Self, Name> library base built on parcel::SelfStructCell.
Root exception hierarchy for the conduit library.
Definition builder.hpp:22
std::vector< char > encode_cbor(const EventEnvelope &env)
Definition serialization.hpp:129
parcel::json_t encode_json(const EventEnvelope &env)
Definition serialization.hpp:125