26#ifndef MYSQL_ROUTER_CLASSIC_PROTOCOL_CODEC_FRAME_H_
27#define MYSQL_ROUTER_CLASSIC_PROTOCOL_CODEC_FRAME_H_
32#include <system_error>
49 template <
class Accumulator>
65 static constexpr size_t max_size() noexcept {
return 4; }
71 auto payload_size_res = accu.template step<wire::FixedInt<3>>();
72 auto seq_id_res = accu.template step<wire::FixedInt<1>>();
76 return std::make_pair(
78 value_type(payload_size_res->value(), seq_id_res->value()));
89class Codec<frame::CompressedHeader>
91 template <
class Accumulator>
114 auto payload_size_res = accu.template step<wire::FixedInt<3>>();
115 auto seq_id_res = accu.template step<wire::FixedInt<1>>();
116 auto uncompressed_size_res = accu.template step<wire::FixedInt<3>>();
120 return std::make_pair(
122 value_type(payload_size_res->value(), seq_id_res->value(),
123 uncompressed_size_res->value()));
138template <
class PayloadType>
139class Codec<frame::Frame<PayloadType>>
141 template <
class Accumulator>
146 .step(PayloadType(v_.payload()))
163 auto header_res = accu.template step<frame::Header>();
169 if (
buffer.
size() < header_size + header_res->payload_size()) {
175 accu.template step<PayloadType>(header_res->payload_size());
179 return std::make_pair(
181 value_type(header_res->seq_id(), payload_res.value()));
constexpr Codec(value_type v, capabilities::value_type caps)
Definition: classic_protocol_codec_frame.h:156
friend __base
Definition: classic_protocol_codec_frame.h:154
const value_type v_
Definition: classic_protocol_codec_frame.h:185
static stdx::expected< std::pair< size_t, value_type >, std::error_code > decode(net::const_buffer buffer, capabilities::value_type caps)
Definition: classic_protocol_codec_frame.h:159
constexpr auto accumulate_fields(Accumulator &&accu) const
Definition: classic_protocol_codec_frame.h:142
Codec for a type.
Definition: classic_protocol_codec_base.h:72
Definition: classic_protocol_wire.h:103
Definition: classic_protocol_frame.h:85
Generator of decoded Types of a buffer.
Definition: classic_protocol_codec_base.h:153
result_type result() const
get result of the step().
Definition: classic_protocol_codec_base.h:219
CRTP base for the Codec's encode part.
Definition: classic_protocol_codec_base.h:374
size_t size() const noexcept
Definition: buffer.h:120
Definition: expected.h:286
constexpr const error_type & error() const &
Definition: expected.h:760
constexpr value_type & value() &
Definition: expected.h:645
Definition: expected.h:112
std::bitset< 32 > value_type
Definition: classic_protocol_constants.h:73
Definition: classic_protocol_binary.h:39
std::error_code make_error_code(codec_errc e) noexcept
Definition: classic_protocol_codec_error.h:86
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:418
Definition: gcs_xcom_synode.h:64
unexpected(E) -> unexpected< E >