morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
morph::wire::WireCodecOps Struct Reference

The serialisation primitive encode calls, as an injectable strategy. More...

#include <wire.hpp>

Public Attributes

std::function< glz::error_ctx(const Envelope &env, std::string &out)> writeEnvelope
 Serialises env into out. Mirrors the glz::write call encode would otherwise make directly.

Detailed Description

The serialisation primitive encode calls, as an injectable strategy.

Same shape and rationale as morph::core::FileIoOps: the member defaults to the real call it stands in for, so a default-constructed WireCodecOps is byte-for-byte what encode did before this seam existed.

Why this exists
encode's write-failure arm is unreachable through any Envelope value. Glaze only sets a write-time error for invalid_partial_key/unknown_key (its partial-write-by-key-list feature, which encode does not use) or invalid_variant_object (a std::variant member, which Envelope does not have). Confirmed by experiment as well as by reading glaze: five flavours of invalid UTF-8, an embedded NUL, a raw control byte and an 8 MiB payload all encode successfully.

That leaves a branch guarding a real invariant with no way to reach it. Rather than reshape Envelope to make a test possible, or wait on a fault-injection hook glaze does not offer, this puts the seam on morph's side of the boundary — where the repository already puts it for the identical problem with file I/O.

Definition at line 881 of file wire.hpp.

Member Data Documentation

◆ writeEnvelope

std::function<glz::error_ctx(const Envelope& env, std::string& out)> morph::wire::WireCodecOps::writeEnvelope
Initial value:
= [](const Envelope& env,
std::string& out) {
std::array<std::string_view, detail::kOmittableEnvelopeKeys.size()> omitted{};
return glz::write_json_exclude<detail::EscapingWriteOpts{}>(env, detail::defaultValuedKeys(env, omitted), out);
}
JSON wire envelope used between any client and RemoteServer.
Definition wire.hpp:91
Write options that escape ASCII control bytes as \\uXXXX sequences.
Definition wire.hpp:401

Serialises env into out. Mirrors the glz::write call encode would otherwise make directly.

Returns
Glaze's error context; falsy on success.

Definition at line 885 of file wire.hpp.


The documentation for this struct was generated from the following file: